Control.ResumeLayout 方法

定义

恢复正常的布局逻辑。

重载

ResumeLayout()

恢复正常的布局逻辑。

ResumeLayout(Boolean)

恢复正常的布局逻辑,可以选择强制对挂起的布局请求立即进行布局。

ResumeLayout()

Source:
Control.cs
Source:
Control.cs
Source:
Control.cs

恢复正常的布局逻辑。

C#
public void ResumeLayout();

示例

下面的代码示例向窗体添加两个按钮。 该示例使用 SuspendLayoutResumeLayout 方法处理按钮的添加。

C#
private void AddButtons()
{
   // Suspend the form layout and add two buttons.
   this.SuspendLayout();
   Button buttonOK = new Button();
   buttonOK.Location = new Point(10, 10);
   buttonOK.Size = new Size(75, 25);
   buttonOK.Text = "OK";

   Button buttonCancel = new Button();
   buttonCancel.Location = new Point(90, 10);
   buttonCancel.Size = new Size(75, 25);
   buttonCancel.Text = "Cancel";
      
   this.Controls.AddRange(new Control[]{buttonOK, buttonCancel});
   this.ResumeLayout();
}

注解

如果有任何挂起的 ResumeLayout 布局请求,调用 方法将强制立即布局。

当你调整控件的多个Layout属性时, SuspendLayoutResumeLayout 方法将结合使用来禁止显示多个事件。 例如,通常调用 SuspendLayout 方法,然后设置控件的 SizeLocationAnchorDock 属性,然后调用 ResumeLayout 方法以使更改生效。

对于 要成功调用SuspendLayoutResumeLayout的 ,必须没有挂起的调用。

另请参阅

适用于

.NET Framework 4.8.1 和其他版本
产品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

ResumeLayout(Boolean)

Source:
Control.cs
Source:
Control.cs
Source:
Control.cs

恢复正常的布局逻辑,可以选择强制对挂起的布局请求立即进行布局。

C#
public void ResumeLayout(bool performLayout);

参数

performLayout
Boolean

若要执行挂起的布局请求,则为 true;否则为 false

注解

如果有任何挂起的 ResumeLayout 布局请求,调用 方法将强制立即布局。 performLayout当 参数设置为 true时,如果有任何挂起的布局请求,则会发生即时布局。

当你调整控件的多个Layout属性时, SuspendLayoutResumeLayout 方法将结合使用来禁止显示多个事件。 例如,通常调用 SuspendLayout 方法,然后设置控件的 SizeLocationAnchorDock 属性,然后调用 ResumeLayout 方法以使更改生效。

对于 要成功调用SuspendLayoutResumeLayout的 ,必须没有挂起的调用。

备注

将多个控件添加到父控件时,建议在初始化要添加的控件之前调用 SuspendLayout 方法。 将控件添加到父控件后,调用 ResumeLayout 方法。 这将提高具有许多控件的应用程序的性能。

另请参阅

适用于

.NET Framework 4.8.1 和其他版本
产品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10