我已经查看了生成的Form s和UserControl s设计器代码,在InitializeComponent()方法中,它们始终以
I have looked at the generated designer code of Forms and UserControls, and in the InitializeComponent() method they always start with
this.SuspendLayout();并以
this.ResumeLayout(false); this.PerformLayout();但是从我在这些方法的msdn文档中所看到的,并不会以
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?
询问,因为我将以另一种方法添加一堆控件,并认为我应该执行suspend-resume例程以使其美观高效.但是无法弄清楚这两个方法调用的原因是什么,当您似乎只能使用一个方法时...
推荐答案使用反射器:
this.ResumeLayout() is equal to this.ResumeLayout(true)但是
this.ResumeLayout(true) is not equal to this.ResumeLayout(false) + this.PerformLayout()原因: 当使用false调用ResumeLayout时,将循环遍历一个控件集合,并且LayoutEngine在布局中的每个控件上调用InitLayout.
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.
更多推荐
C#:ResumeLayout(true)是否与ResumeLayout(false)+ PerformLayout()一样?
发布评论