다음을 통해 공유


Control.Layout 이벤트

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Event Layout As LayoutEventHandler
‘사용 방법
Dim instance As Control
Dim handler As LayoutEventHandler

AddHandler instance.Layout, handler
public event LayoutEventHandler Layout
public:
event LayoutEventHandler^ Layout {
    void add (LayoutEventHandler^ value);
    void remove (LayoutEventHandler^ value);
}
/** @event */
public void add_Layout (LayoutEventHandler value)

/** @event */
public void remove_Layout (LayoutEventHandler value)
JScript에서는 이벤트를 사용할 수 있지만 새로 선언할 수는 없습니다.

설명

Layout 이벤트는 자식 컨트롤을 추가하거나 제거할 때, 해당 컨트롤의 범위를 변경할 때, 해당 컨트롤의 레이아웃에 영향을 줄 수 있는 기타 변경 내용이 있을 때 발생합니다. SuspendLayoutResumeLayout 메서드를 사용하면 레이아웃 이벤트가 발생하지 않도록 할 수 있습니다. 레이아웃을 일시 중단하면 각 변경 사항에 대해 레이아웃을 수행하지 않아도 하나의 컨트롤에서 여러 작업을 수행할 수 있습니다. 예를 들어, 컨트롤의 크기를 조정하거나 이동할 때마다 Layout 이벤트가 발생합니다.

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

예제

다음 코드 예제에서는 Layout 이벤트가 발생할 때 Form을 화면 가운데로 정렬합니다. 이렇게 하면 사용자가 폼의 크기를 변경하더라도 폼이 가운데로 정렬됩니다. 이 예제를 실행하려면 Form 컨트롤이 만들어져 있어야 합니다.

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
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 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).get_Width() 
        / 2 - this.get_Width() / 2, Screen.GetBounds(this).get_Height() 
        / 2 - this.get_Height() / 2, this.get_Width(), this.get_Height(), 
        BoundsSpecified.Location);
} //MyForm_Layout

플랫폼

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

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

Control 클래스
Control 멤버
System.Windows.Forms 네임스페이스
OnLayout
InitLayout
SuspendLayout
ResumeLayout
Control.LayoutEngine 속성
Control.Layout 이벤트
PerformLayout