Reputation: 19
I have a C# application with a mainform and several custom user controls on it.
When I move the mainform, the user controls keep repainting and they repaint again when I stop moving the mainform.
What can I do to disable this repainting?
Upvotes: 0
Views: 3475
Reputation: 14409
An answer to this previous question discusses how to use the WM_SETREDRAW Win32 API to suspend and resume drawing. It includes a nice wrapper class; maybe it will help you.
Upvotes: 2
Reputation: 1178
You should not have to forcefully Invalidate() yourself. I assume you are doing some custom painting in the control? Within the constructor after the InitializeComponent(); do you have
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
?
Upvotes: 0
Reputation: 3580
If its flickering thats annoying you, you could try and set the DoubleBuffered property on the control to true.
Other than that you could subscribe the forms move event and turn off painting on the child controls in a similar fashion to whats described in this question...
Upvotes: 0