jmayor
jmayor

Reputation: 2795

Stop controls from being painted

I have a User Control that has some WinForm Controls inside. I want to be able to paint those inner controls myself (for scrolling purposes, some of them will remain, others will move).

Even when I override the OnPaint and the OnPaintBackground method, those controls keeps showing on my usercontrol which is completely black now because there is no painting methods on it.

Is there a way I can suppress those controls from been painted and then paint them by myself with the DrawToBitmap method of each control?

Upvotes: 0

Views: 404

Answers (2)

Dan Byström
Dan Byström

Reputation: 9244

If you don't need interaction, just set every child control .Visible = false.

Otherwise, have you tried WM_SETREDRAW?

Upvotes: 1

PeterAllenWebb
PeterAllenWebb

Reputation: 10408

Yes. Remove them from (or better yet, never add them to) the UserControl's set of child controls. Simulating interaction with the controls is going to be a PITA, though.

Do you just need the controls to "look" like they're there. Or do they need to actually be there? If its the latter, you would be better off faking the scrolling somehow by just repositioning the controls manually.

Trying to re-invent the windowing system is an exercise in pain. You will be better off if you learn and work within its paradigms.

Upvotes: 1

Related Questions