Control.Layout Zdarzenie

Definicja

Występuje, gdy formant powinien zmienić położenie swoich formantów podrzędnych.

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 

Typ zdarzenia

Przykłady

Poniższy przykład kodu koncentruje się Form na ekranie w zdarzeniu Layout . Spowoduje to, że formularz będzie wyśrodkowany, gdy użytkownik zmieni jego rozmiar. Ten przykład wymaga utworzenia kontrolki 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

Uwagi

Zdarzenie Layout występuje, gdy kontrolki podrzędne są dodawane lub usuwane, gdy granice kontrolki się zmieniają, oraz gdy wystąpią inne zmiany, które mogą mieć wpływ na układ kontrolki. Zdarzenie układu można pominąć przy użyciu SuspendLayout metod i ResumeLayout . Zawieszenie układu pozwala wykonać wiele operacji na formancie bez konieczności egzekwowania układu dla każdej zmiany. Jeśli na przykład zmieniasz rozmiar i przenosisz kontrolkę Layout , każda operacja zgłosi zdarzenie.

Aby uzyskać więcej informacji na temat obsługi zdarzeń, zobacz Obsługa i podnoszenie zdarzeń.

Dotyczy

Zobacz też