English 中文(简体)
C#: 恢复停业(停业)是否与恢复休庭(false)+演习相同?
原标题:C#: Does ResumeLayout(true) do the same as ResumeLayout(false) + PerformLayout()?
  • 时间:2009-08-27 08:49:40
  •  标签:

我研究了生成的<代码>设计商代码。 表格和<编码>UserControls 和InitializeComponent( 方法 始终以开始

    this.SuspendLayout();

页: 1

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

但是,从我能够看到的这些方法的拼凑文件来看,最终将结束。

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

究竟是什么样子? 或者我在这里没有什么东西?

<>放弃,因为我将以不同方法增加一套控制,我认为,暂停适用例行做法是ice和高效的。 但可以说明这两种方法的用意是,当你似乎只使用一种......时。

最佳回答

使用反射器:

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

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.

问题回答

<>SuspendLayout>

When adding several controls to a parent control, it is recommended that you call the SuspendLayout method before initializing the controls to be added. After adding the controls to the parent control, call the ResumeLayout method. This will increase the performance of applications with many controls.

<>PerformLayout>

It forces the control to apply layout logic to all its child controls. If the <>SuspendLayout> method was called before calling the PerformLayout method, the Layout event is suppressed. The layout event can be suppressed using the SuspendLayout and ResumeLayout methods.

MSDN Link -





相关问题
热门标签