Draw a line on a form

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Hi All,

I am sure this is a simple question, but how do I draw a
line onto a windows form in VB.NET, or any shape for that
matter. VB6 had a line and shape control that you could
use.

Thanks,
Steve
 
Steve said:
Hi All,

I am sure this is a simple question, but how do I draw a
line onto a windows form in VB.NET, or any shape for that
matter. VB6 had a line and shape control that you could
use.

At design time you can use a Label control and set it's height, or width to
1 (I like to use 2px and set the border to 3D - nice chiseled effect). There
are also several home-grown line controls. Or you can draw them manually at
runtime using GDI+ (System.Drawing namespace).

HTH,
Jeremy
 
Steve said:
I am sure this is a simple question, but how do I draw a
line onto a windows form in VB.NET, or any shape for that
matter. VB6 had a line and shape control that you could
use.


Override the Form's OnPaint method. Use e.graphics to draw graphics.

Outside the OnPaint procedure:
dim g as graphics
g = Me.creategraphics
'draw on g here
'...
g.dispose
 
Hi All,

I am sure this is a simple question, but how do I draw a
line onto a windows form in VB.NET, or any shape for that
matter. VB6 had a line and shape control that you could
use.

Thanks,
Steve

Hey,,,,,,

The best option is to draw a label, set their properties as:

1) Clear the text property

2)set Autosize property to false

3)set back color as reqiured

4)set enabled property as false or else it can be moved at run time

5) use Shift+ arrows to resize the label...

like shift+up arrow to make thin line and shift+left to make small line etc
 
Back
Top