Dashed Label [Design Mode Only]

Sometimes you have so many controls on your design form that can make you confused.  So i have developed a Dashed Label Control which provide each control a boundry in Design Mode only. For better Understanding see the Screen Shots Below:

Design Mode

At Run Time

I hope your getting what i am saying.

Now to the Code.

1. Add a custom Control to your project. Name is DashedLabel (or anything you like.)
2. Now on its Paint Event Write the following Code.

private void DashedLabel_Paint(object sender, PaintEventArgs e)
if (this.DesignMode)
using (Pen pen = new Pen(Color.Gray))
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
e.Graphics.DrawRectangle(pen, 0, 0, this.Width - 1, this.Height - 1);

That’s it.

Complete Project : Dashed Label


Leave a Reply

Your email address will not be published. Required fields are marked *