I have a control which I have to make large modifications to. I’d like to completely prevent it from redrawing while I do that – SuspendLayout and ResumeLayout aren’t enough. How do I suspend painting for a control and its children?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
At my previous job, we struggled with getting our rich UI app to paint instantly and smoothly. We were using standard .Net controls, custom controls and devexpress controls.
After a lot of googling and reflector usage, I came across the WM_SETREDRAW win32 message. This really stops controls drawing whilst you update them and can be applied, IIRC to the parent/containing panel.
This is a very very simple class demonstrating how to use this message:
There are fuller discussions on this – google for C# and WM_SETREDRAW, e.g.
C# Jitter
Suspending Layouts
And to whom it may concern, this is a similar example in VB: