Control.Layout 이벤트

정의

컨트롤이 자식 컨트롤의 위치를 변경하면 발생합니다.

public:
 event System::Windows::Forms::LayoutEventHandler ^ Layout;
public event System.Windows.Forms.LayoutEventHandler Layout;
public event System.Windows.Forms.LayoutEventHandler? Layout;
member this.Layout : System.Windows.Forms.LayoutEventHandler 
Public Custom Event Layout As LayoutEventHandler 

이벤트 유형

예제

다음 코드 예제에서는 이벤트의 화면에 을 가운데 Form 에 입니다 Layout . 이렇게 하면 양식의 크기가 조정될 때 양식의 중심이 유지됩니다. 이 예제에서는 컨트롤을 만들어야 합니다 Form .

private:
   void MyForm_Layout( Object^ /*sender*/, System::Windows::Forms::LayoutEventArgs^ /*e*/ )
   {
      // Center the Form on the user's screen everytime it requires a Layout.
      this->SetBounds( (Screen::GetBounds( this ).Width / 2) - (this->Width / 2), (Screen::GetBounds( this ).Height / 2) - (this->Height / 2), this->Width, this->Height, BoundsSpecified::Location );
   }
private void MyForm_Layout(object sender, System.Windows.Forms.LayoutEventArgs e)
{
   // Center the Form on the user's screen everytime it requires a Layout.
   this.SetBounds((Screen.GetBounds(this).Width/2) - (this.Width/2),
       (Screen.GetBounds(this).Height/2) - (this.Height/2),
       this.Width, this.Height, BoundsSpecified.Location);	
}

Private Sub MyForm_Layout(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.LayoutEventArgs) Handles MyBase.Layout

    ' Center the Form on the user's screen everytime it requires a Layout.
    Me.SetBounds((System.Windows.Forms.Screen.GetBounds(Me).Width / 2) - (Me.Width / 2), _
        (System.Windows.Forms.Screen.GetBounds(Me).Height / 2) - (Me.Height / 2), _
        Me.Width, Me.Height, System.Windows.Forms.BoundsSpecified.Location)
End Sub

설명

Layout 자식 컨트롤을 추가 하거나 범위 컨트롤 변경 하 고 있는 다른 변경 내용이 있을 수는 컨트롤의 레이아웃에 영향을 받는 경우 제거 하면 오류가 발생 합니다. 및 ResumeLayout 메서드를 사용하여 SuspendLayout 레이아웃 이벤트를 표시하지 않을 수 있습니다. 레이아웃을 일시 중단을 사용 하면 각 변경에 대 한 레이아웃을 수행 하지 않고 컨트롤에 여러 작업을 수행할 수 있습니다. 예를 들어, 크기를 조정 하는 컨트롤을 이동 하는 경우 각 작업 발생을 Layout 이벤트입니다.

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.

적용 대상

추가 정보