can't invoke paint

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 02:58:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!