简体   繁体   中英

can't invoke paint

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?

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM