In addition to the idea of the design Pete offered in his answer, I would like to emphasize that you should not use
PictureBox
. All you need is a custom control derived from
System.Windows.Forms.Control
and do all the rendering in the handler of the event
Paint
or, better yet, in the overridden protected virtual method
OnPaint
.
The
PictureBox
is good only for simple presentation of a static picture, maybe replaced from time to time. Using this class for anything interactive, dynamic of animated is the abuse of it. In such cases,
PictureBox
does not provide any benefits, only extra hassles in development; it simply eats up some extra resources, performance and your development time offering nothing in return.
I explain it in detail in my past answers:
How do I clear a panel from old drawing[
^],
draw a rectangle in C#[
^].
See also my other past answers on related topics:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[
^],
Drawing Lines between mdi child forms[
^],
capture the drawing on a panel[
^].
—SA