I would try to add
System.Windows.Forms.ControlStyles
AllPaintingInWmPaint | OptimizedDoubleBuffer
using
System.Windows.Forms.Control.Control.SetStyle
, see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.setstyle.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.setstyle.aspx[
^].
Also, I would derive your class from
Control
and did not call base
OnPaint
(and paint the background yourself), as you don't need any functionality specific to
Panel
.
However, I don't see anything fundamentally wrong in your code; I would even suspect that something is wrong with your system. I remember I had some Forms artifacts showing on Windows 2000 but never on XP. So, I would suggest you try your code on different systems, just in case.
—SA