Hi friends,
I am drawing several circles/recatangles etc. with this code but whenever I use to minimize the form of other form come on its front the drawings get erased.
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
System.Drawing.Graphics formGraphics = panelforImage.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 200, 150));
myBrush.Dispose();
formGraphics.Dispose();
Please help me out.
The drawing get erased on minimizing the form
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Jean PaulRank #32 · 38.5K reputationPosted Dec 1, 2010, 5:48 AM EST
and your custom drawings will be lost.
There are two solutions i could suggest you:
1) Do the drawing in the paint event of the panel (may be you have to derive a custom panel for it)
or
2) Do the drawings in a Bitmap object, that should retain the pixel values.
iinf19 reputationPosted Dec 19, 2010, 8:45 PM EST