Control.SuspendLayout Method

Temporarily suspends the layout logic for the control.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

Public Sub SuspendLayout
Dim instance As Control

public void SuspendLayout ()
public function SuspendLayout ()

The layout logic of the control is suspended until the ResumeLayout method is called.

The SuspendLayout and ResumeLayout methods are used in tandem to suppress multiple Layout events while you adjust multiple attributes of the control. For example, you would typically call the SuspendLayout method, then set the Size, Location, Anchor, or Dock properties of the control, and then call the ResumeLayout method to enable the changes to take effect.

The SuspendLayout calls must be equal to zero before ResumeLayout can be successfully called.


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.

The following code example adds two buttons to a form. The example transactions the addition of the buttons by using the SuspendLayout and ResumeLayout methods.

Private Sub AddButtons()
   ' Suspend the form layout and add two buttons.
   Dim buttonOK As New Button()
   buttonOK.Location = New Point(10, 10)
   buttonOK.Size = New Size(75, 25)
   buttonOK.Text = "OK"
   Dim buttonCancel As New Button()
   buttonCancel.Location = New Point(90, 10)
   buttonCancel.Size = New Size(75, 25)
   buttonCancel.Text = "Cancel"
   Me.Controls.AddRange(New Control() {buttonOK, buttonCancel})
End Sub

private void AddButtons()
    // Suspend the form layout and add two buttons.
    Button buttonOK = new Button();
    buttonOK.set_Location(new Point(10, 10));
    buttonOK.set_Size(new Size(75, 25));

    Button buttonCancel = new Button();
    buttonCancel.set_Location(new Point(90, 10));
    buttonCancel.set_Size(new Size(75, 25));

    this.get_Controls().AddRange(new Control[] {buttonOK, buttonCancel});
} //AddButtons

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

Community Additions