Instead of
OnPaintBackground
(its purpose is different), override
OnPaint
:
Control.OnPaint Method (PaintEventArgs) (System.Windows.Forms)[
^].
Alternatively, you can handle the corresponding event
System.Windows.Drawing.Control.Paint
. But you don't need it because you are writing derived class anyway, so overriding is not a problem. By the way, if you override the method, don't handle this event (you could do it both, but usually it's poinless) and don't want the users to handle this event, don't call
base.Paint
.
—SA