Control.SuspendLayout 메서드

정의

컨트롤의 레이아웃 논리를 일시적으로 일시 중단합니다.

public:
 void SuspendLayout();
public void SuspendLayout();
member this.SuspendLayout : unit -> unit
Public Sub SuspendLayout ()

예제

다음 코드 예제에서는 폼에 두 개의 단추를 추가합니다. 이 예제에서는 단추 및 SuspendLayout 메서드를 사용하여 단추 추가를 ResumeLayout 트랜잭션합니다.

private:
   void AddButtons()
   {
      // Suspend the form layout and add two buttons.
      this->SuspendLayout();
      Button^ buttonOK = gcnew Button;
      buttonOK->Location = Point(10,10);
      buttonOK->Size = System::Drawing::Size( 75, 25 );
      buttonOK->Text = "OK";
      Button^ buttonCancel = gcnew Button;
      buttonCancel->Location = Point(90,10);
      buttonCancel->Size = System::Drawing::Size( 75, 25 );
      buttonCancel->Text = "Cancel";
      array<Control^>^temp5 = {buttonOK,buttonCancel};
      this->Controls->AddRange( temp5 );
      this->ResumeLayout();
   }
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();
}
Private Sub AddButtons()
   ' Suspend the form layout and add two buttons.
   Me.SuspendLayout()
   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})
   Me.ResumeLayout()
End Sub

설명

메서드가 호출될 때까지 컨트롤의 레이아웃 논리가 ResumeLayout 일시 중단됩니다.

컨트롤 SuspendLayoutResumeLayout 여러 특성을 조정하는 동안 여러 Layout 이벤트를 표시하지 않는 데와 메서드가 함께 사용됩니다. 예를 들어 일반적으로 메서드를 SuspendLayout 호출한 다음 컨트롤의 , Size또는 LocationAnchor 속성을 설정한 Dock다음, 메서드를 호출 ResumeLayout 하여 변경 내용을 적용할 수 있도록 합니다.

성공적으로 호출되려면 SuspendLayoutResumeLayout 보류 중인 호출이 없어야 합니다.

메모

부모 컨트롤에 여러 컨트롤을 추가할 때 추가할 컨트롤을 초기화하기 전에 메서드를 호출 SuspendLayout 하는 것이 좋습니다. 부모 컨트롤에 컨트롤을 추가한 후 메서드를 호출합니다 ResumeLayout . 이렇게 하면 많은 컨트롤을 사용하는 애플리케이션의 성능이 향상됩니다.

적용 대상

추가 정보