KnowDotNet

Replacing the Line Control in VB6

Be Creative

by Les Smith

In VB6, there was a Line Control, but there is none in .NET.  How do I draw a line on a form?  A Label control with a minimum height makes a nice replacement for the Line control in VB6.  To make a Label control look like a line, follow these steps.

1. Set the BorderStyle to FixedSingle.
2. Set the size to nnn,1 for example to get the narrow horizontal line, or 1,nnn to get a narrow vertical line.
3. Clear the Text property, of course.
4. If you want to make the size wider, set the BackgroundColor to Black, and increase the respective size.

Figure 1 shows a form with lines, all comprised of Label Controls.

Figure 1 - Line Controls Replaced by Label Controls.

Line