Control.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 이벤트는 자식 컨트롤을 추가하거나 제거할 때, 컨트롤의 범위가 변경될 때, 컨트롤의 레이아웃에 영향을 줄 수 있는 다른 변경이 발생할 때 발생합니다. 및 메서드를 사용하여 SuspendLayoutResumeLayout 레이아웃 이벤트를 표시하지 않을 수 있습니다. 레이아웃을 일시 중단하면 각 변경에 대해 레이아웃을 수행할 필요 없이 컨트롤에서 여러 작업을 수행할 수 있습니다. 예를 들어 컨트롤의 크기를 조정하고 이동하면 각 작업에서 이벤트가 발생합니다 Layout .

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

적용 대상

추가 정보