Remember VB6's good-old Autoredraw property for forms and pictureboxes etc?
What is the equivalent code in VB.net? I'm trying to draw lines on a form but they wont stay put if I minimize/maximize the form.
Printable View
Remember VB6's good-old Autoredraw property for forms and pictureboxes etc?
What is the equivalent code in VB.net? I'm trying to draw lines on a form but they wont stay put if I minimize/maximize the form.
I think you can use .Refresh.......I think!
Unfortunately not, that has the opposite effect.
Anyone else?
When you create an instance of the graphics instance, and point it to a form, you are simply drawing on the form. Once the form refreshes, you lose anything you have drawn.
The reason is when the OS or the form event handler tells the form to redraw itself, it only draws what is in its Paint event. If you want something to persist, you must take of it there.
You need to add your own code that basically determines if it should add something to the paint event, or gloss over it.
VB Code:
If _PaintLines Then 'loop through my shapes collection 'and draw them End If
just to make it more clear:D
put your draw code in the paint even of the form. This may be sometimes inefficient, as everytime the form is "refreshed" it will redraw everything again. But sometimes this is better, I dont know, depends to you
the other way would be to draw the image on a bitmap or an Image object, and then set that to your form's backgroundImage. If you do this one, you wont have to redraw it. it will just stay there, just as you would have a picture in a picturebox
That sounds promising, thanks, I'll try it.