Box with pictures

In VisualBasic.Net When I activate a window with an image and then draw something on it, it draws and then disappears immediately. Works great when I draw it again, but almost always randomly draw it for the first time. This happened with several different programs, and the help file did not help.

+3
source share
6 answers

Try setting the DoubleBuffered property.

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered.aspx

If this is not the case, please provide additional information.

+1
source

Usually, if you draw something in the image window or on another control, you need to take the OnPaint event, and you are responsible for what you painted on this event.

+1
source

Thank you, Andrey, but no help. I am using .Net Framework 1.1, which does not offer the DoubleBuffered property ... it was new in version 2.0.

I don’t know what additional information you can provide .. code 300 lines long. When the button is pressed, the code expands my form, displays two drawers with pictures (one on top of the other (back for some graph labels), and then uses some graphic brushes and pens to draw a graph on the front panel In some cases, database activity and calculations occur in the background.

0
source

I assume that you are using the standard PictureBox component. Do you draw in Paint-Handler? If not, then the PictureBox will simply delete your drawn material the next time it asks you to redraw (erase the background, etc.).

0
source

Yes, I suppose I'm using a standard picture.

Through Paint-Handler, I assume that you mean the [Control] .PaintEvent handler. Not. I do not use an event handler for drawing. The drawing of my chart is not an event in itself, but part of a much larger response to a button click event.

If you say that the presence of the drawing code is part of a separate and specific handler, it can solve my problem, than I assume that every time I want to redraw the chart, I could create an internal event. But I would rather just figure out what makes PB redraw itself without telling.

0
source

If you cannot use DoubleBuffered, you can HIDE the second snapshot. You draw a drawing in it, and as soon as it finishes, you return to the VISIBLE. Thus, the drawing process is performed on hidden, and white / flicker will not be displayed.

0
source

All Articles