Control.Layout Evento

Definição

Ocorre quando um controlo deve reposicionar os seus controlos filhos.

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 

Tipo de Evento

Exemplos

O seguinte exemplo de código centra a Form no ecrã do Layout evento. Isto manterá o formulário centrado à medida que o utilizador o redimensiona. Este exemplo exige que tenhas criado um Form controlo.

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

Observações

O Layout evento ocorre quando os controlos filhos são adicionados ou removidos, quando os limites do controlo mudam e quando ocorrem outras alterações que podem afetar a disposição do controlo. O evento de layout pode ser suprimido usando os SuspendLayout métodos e.ResumeLayout Suspender o layout permite-lhe realizar múltiplas ações num controlo sem ter de executar um layout para cada alteração. Por exemplo, se redimensionares e moveres um controlo, cada operação geraria um Layout evento.

Para obter mais informações sobre como manipular eventos, consulte Manipulando e gerando eventos.

Aplica-se a

Ver também