Svi*_*ish 11 c# generated-code windows-forms-designer winforms
我已经查看了生成的Forms和UserControls的设计器代码,并且在InitializeComponent()方法中它们始终以
this.SuspendLayout();
Run Code Online (Sandbox Code Playgroud)
结束
this.ResumeLayout(false);
this.PerformLayout();
Run Code Online (Sandbox Code Playgroud)
但是从这些方法的msdn文档中我可以看到,不会以
this.ResumeLayout(true); // Or just this.ResumeLayout()
Run Code Online (Sandbox Code Playgroud)
做同样的事情?或者我在这里遗漏了什么?
问,因为我将在一个不同的方法中添加一堆控件,并认为我应该执行suspend-resume例程以获得高效和高效.但是当你看似只使用一个时,无法弄清楚这两个方法调用的原因是什么......
使用反射器:
this.ResumeLayout() is equal to this.ResumeLayout(true)
Run Code Online (Sandbox Code Playgroud)
但
this.ResumeLayout(true) is not equal to this.ResumeLayout(false) + this.PerformLayout()
Run Code Online (Sandbox Code Playgroud)
原因:
使用false调用ResumeLayout时,将循环遍历一个控件集合,并且LayoutEngine在布局中的每个控件上调用InitLayout。
| 归档时间: |
|
| 查看次数: |
11043 次 |
| 最近记录: |