14

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?

Juan
  • 15,274
  • 23
  • 105
  • 187
  • I would guess that's not the problem. Is this when you are loading a form, or just in general? And are these custom controls you've created? – Brandon Moore Nov 21 '11 at 03:20
  • @BrandonMoore: Yes, these are custom controls and I'm trying to find other problems, but if you know the answer to my question please let me know since I wanted to know this before anyway, and also so I can discard this option. – Juan Nov 21 '11 at 03:22

2 Answers2

21

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.

KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
0

My educated guess would be no, but my advice would be to try anyway and see if it helps. These questions might provide you with a solution: How do I suspend painting for a control and its children?, Winforms: SuspendLayout/ResumeLayout is not enough?

Community
  • 1
  • 1
Brandon Moore
  • 8,590
  • 15
  • 65
  • 120