问题
I created my own control and overwritten the onpaint event, the problem is that the paint event stopped working
Any ideas why? And how to restore it?
回答1:
Let's have a telepathic guess here:
You forgot to call base.OnPaint(...)
inside your override. Meaning that the base functionality is no longer invoked.
回答2:
Maybe the control is obscured. I had a similar problem, and the problem was that the form in the Designer view was bigger than the actual form when the application was run. My custom control had anchors on all sides, and when the main form was reduced in size, the custom control went to zero size (actually negative I guess).
In this mode, the OnPaint override nor a delegate assigned to the Paint event is not called at all.
Maximize your form and make sure that you didn't accidentally reduce the size to zero!
来源:https://stackoverflow.com/questions/4843387/cant-invoke-paint