I have been at this for a few days and it is driving me mad. I have a control that inherits from System.Windows.Forms.Panel and I\'m trying to override OnPaint. It just plai
Call this.Invalidate()
when you want to call OnPaint
I have the same problem just with a ProgressBar, when i try to override the OnPaint.. It's never called.
I found the solution here: http://web.archive.org/web/20140214234801/http://osix.net/modules/article/?id=826
You must create a constructor and enable user-painting like this:
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
Default values, probably vary depending on framework version and OS.