Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to call SuspendLayout for every child control?

Tags:

c#

winforms

Can't find any information about this. My controls are rendering extremely slow and I noticed I'm not calling SuspendLayout when doing major updates.

What I'm in doubt is, since the top level control contains controls which contain other controls and so on, will calling SuspendLayout on my top control also suspend layout for every nested control or do I need to call it for each of them?

like image 419
Juan Avatar asked Nov 21 '11 03:11

Juan


1 Answers

Take a look at this MSDN article - Practical Tips For Boosting The Performance Of Windows Forms Apps.

Text from article : Remember that SuspendLayout only prevents Layout events from being performed for that particular control. If controls are added to a panel, for example, SuspendLayout and ResumeLayout must be called for the panel and not for the parent form.

like image 113
KV Prajapati Avatar answered Oct 11 '22 14:10

KV Prajapati