C#: Does ResumeLayout(true) do the same as ResumeLayout(false) + PerformLayout()?

Svish picture Svish · Aug 27, 2009 · Viewed 12.1k times · Source

I have looked at the generated designer code of Forms and UserControls, and in the InitializeComponent() method they always start with

    this.SuspendLayout();

and end with

    this.ResumeLayout(false);
    this.PerformLayout();

But from what I can see in the msdn documentation of those methods, wouldn't ending with

    this.ResumeLayout(true); // Or just this.ResumeLayout()

do the exact same thing? Or am I missing something here?

Asking because I will be adding a bunch of controls in a different method, and thought I should do the suspend-resume routine to be nice and efficient. But can't figure out what the reason for those two method calls are when you can seemingly just use one...

Answer

SwDevMan81 picture SwDevMan81 · Aug 27, 2009

Using reflector:

this.ResumeLayout() is equal to this.ResumeLayout(true)

But

this.ResumeLayout(true) is not equal to this.ResumeLayout(false) + this.PerformLayout()

Reason:
When ResumeLayout is called with false, there is a control collection that is looped through and the LayoutEngine calls InitLayout on each of the controls in the layout.