Draw a line on a form

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
 
J

Jeremy Cowles

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
 
A

Armin Zingler

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
 
Joined
Mar 12, 2013
Messages
1
Reaction score
0
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top