public void printGraphics()
{
g =
this.pictureBox1.CreateGraphics(); //pictureBox1.Refresh();pictureBox1.Invalidate();
Pen myPen =
new Pen(Color.Blue);myPen.Width = 1;
for(int i = 0; i < a.Length; i++){
g.DrawEllipse(myPen,i, a[ i ], 2, 2);
}
//pictureBox1.Invalidate();}
Does anyone have any idea why the last loop(s) the images are not visible anymore
Thanks all,
Zath

control.invalidate
Antara
Second, when you call the Invalidate method, your basically telling the framework that "Right after I'm finished doing this stuff, please repaint the PictureBox any way you like it".
The Refresh method instead tells the framework to "Repaint the PictureBox right now!". That's why you get flicker.
Technically speaking, Invalidate() places a WM_PAINT message in the PictureBox's message queue. When the messages gets handled, the PictureBox's OnPaint method gets called. The framework paints the PictureBox using the BackColor color and the Image object, then raises the Paint event. The Refresh method instead invokes the OnPaint method directly.
You should instead place your rendering code (from Pen myPen = ... to and including the for loop) inside the Paint event of your PictureBox object. That makes your painting code fire when it needs to be fired. Within the Paint event, you can use the e.Graphics object instead of creating your own Graphics object.
If you want to get a better piece of code, you should consider deriving your own class from PictureBox and override the OnPaint method.
Last of all - a note on flickering. Try setting the DoubleBuffering property to True and see what happens.