Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I postpone the resizing controls until the form's resizing is complete?

I have a form with several controls on it. As I size the form, the controls are being resized continuously. Is it possible to postpone changing the controls position until the resizing is complete?

The idea is to do the painting on Idle. This means you simple invalidate when being sized and then do your full paint when the size completes. Here is the code that you would add to your form.

bool idleHooked = false; 
protected override void OnResize(EventArgs e) 
{ 
if (!idleHooked) 
{ 
Application.Idle += new EventHandler(OnIdle); 
} 
} 
private void OnIdle(object s, EventArgs e) 
{ 
Invalidate(); 
PerformLayout(); 
if (idleHooked) 
{ 
Application.Idle -= new EventHandler(OnIdle); 
} 
}

George Shepherd, Syncfusion, and Shawn Burke, Microsoft



Page view counter