Drawing One Simple Little Line

P

Peter

Hi,

I remember in VB6 that one could simply draw a line in a picturebox using
the .Line method. There is no equivalent in .NET; everything I read says it
is necessary to do lots of heavily complicated things to get it to happen.

My question is, most of those new methods (the ones that take 25 lines of
code) require that the drawing takes place in the OnPaint event of the
picture box. This seems to imply that whatever is drawn in there must remain
static for the whole program. How can one dynamically change, add, and erase
lines, circles, and so forth during runtime?
 
M

Michael C

Peter said:
Hi,

I remember in VB6 that one could simply draw a line in a picturebox using
the .Line method. There is no equivalent in .NET; everything I read says
it is necessary to do lots of heavily complicated things to get it to
happen.

My question is, most of those new methods (the ones that take 25 lines of
code) require that the drawing takes place in the OnPaint event of the
picture box. This seems to imply that whatever is drawn in there must
remain static for the whole program. How can one dynamically change, add,
and erase lines, circles, and so forth during runtime?

I don't know how you get 25 lines of code. In the onpaint override just draw
the line using e.Graphics.DrawLine. If you want to change what you're
drawing then just draw a different line in OnPaint.

Michael
 
R

rowe_newsgroups

Hi,

I remember in VB6 that one could simply draw a line in a picturebox using
the .Line method. There is no equivalent in .NET; everything I read says it
is necessary to do lots of heavily complicated things to get it to happen.

My question is, most of those new methods (the ones that take 25 lines of
code) require that the drawing takes place in the OnPaint event of the
picture box. This seems to imply that whatever is drawn in there must remain
static for the whole program. How can one dynamically change, add, and erase
lines, circles, and so forth during runtime?

You don't have to use the OnPaint override, you can also get the
Graphics object by doing "Dim g as Graphics =
PictureBox.CreateGraphics." And in reality, once you get used to using
GDI+ to do the drawing you will like it better than the VB6 methods
(or at least I do).

Thanks,

Seth Rowe
 
M

Michael C

rowe_newsgroups said:
You don't have to use the OnPaint override, you can also get the
Graphics object by doing "Dim g as Graphics =
PictureBox.CreateGraphics."

How are you going to paint again when it disappears though?
And in reality, once you get used to using
GDI+ to do the drawing you will like it better than the VB6 methods
(or at least I do).

I totally and utterly agree. Dotnet's drawing is *far far* superior. Only
downside is the speed.

Michael
 

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

Similar Threads

VB 2005 graphics concepts 12
Redrawing a part of a control 2
AutoSize Issues 1
drawing snap mode indicator 1
Drawing question 4
Drawing 2
VB2005 line drawing speedup 4
Lines crossing 2

Top