Override the OnPaint () method of your form or implement the Paint event of the control. Use the resulting e.Graphics object for drawing. It will be correctly initialized to draw smooth lines. And it can be a double buffer so that it does not flicker. Call Invalidate () to force the redraw.
Using Control.CreateGraphics () is incorrect in 99.9% of all cases. Everything you draw cannot go on. It will disappear when you minimize and restore the window. Or when you partially move it from the screen and back. Or when you overlay another window on your XP computer and on any machine on which Aero is not enabled. CreateGraphics () is only suitable for animations with a frame rate of more than ~ 20 frames per second.
source share