You should place the drawing code in the Paint
event handler of the PictureBox
, and use the Graphics
provided in the event args. This way, your custom drawing code will be executed every time the control is redrawn.
If you don't do it this way, anything you draw will disappear the next time the control is redrawn. In your code, you call Invalidate
right after you draw your ellipse, so the control is redrawn without the ellipse...