Prevent window redraw when resizing c# windows forms

Daniel picture Daniel · Mar 1, 2010 · Viewed 12.6k times · Source

What windows message or event can i listen to in order to stop a window from being redrawing every pixel of it's resize?

That is, when a user clicks on the edge of the window and starts to re-size it, i don't want to re-draw the entire contents until he lets go. This is because for some reason it's currently choppy at resizing probably because everything is re-docking and what not.

I tried WM_SIZING but that only tells me it's being re-sized, i wish to know the start and end of the sizing so i can suspend the layout until the user stops resizing.

Answer

Daniel picture Daniel · Mar 1, 2010

Nevermind, just found these two events.

this.ResizeBegin += (s, e) => { this.SuspendLayout(); };
this.ResizeEnd += (s, e) => { this.ResumeLayout(true); };

Works a treat