Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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...

like image 957
Svish Avatar asked Aug 27 '09 08:08

Svish


1 Answers

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.

like image 200
SwDevMan81 Avatar answered Sep 24 '22 14:09

SwDevMan81