The CustomSnapline project shows how to add a text baseline snapline to a UserControl with a Label on it.

5,000 times
Add to favorites
E-mail Twitter Digg Facebook

Solution explorer

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Windows.Forms.Design.Behavior;
using System.Collections.ObjectModel;
using System.Collections;

namespace CustomSnapline
    public partial class ControlWithCustomSnapline : UserControl
        public ControlWithCustomSnapline()

    // To provide a custom snapline for your control you need to 
    // override the SnapLines property on ControlDesigner
    // This simple example adds a text baseline snapline to a
    // UserControl with a Label on it.
    public class ControlWithCustomSnaplineDesigner : ControlDesigner
        public override System.Collections.IList SnapLines
                ArrayList snapLines = base.SnapLines as ArrayList;

                foreach (Control c in Control.Controls)
                    if (c is Label)
                        snapLines.Add(new SnapLine(SnapLineType.Baseline, c.Top + c.Height));

                return snapLines;