Control.SetBounds Método

Definición

Establece los límites del control.

Sobrecargas

Nombre Description
SetBounds(Int32, Int32, Int32, Int32)

Establece los límites del control en la ubicación y el tamaño especificados.

SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified)

Establece los límites especificados del control en la ubicación y el tamaño especificados.

SetBounds(Int32, Int32, Int32, Int32)

Establece los límites del control en la ubicación y el tamaño especificados.

public:
 void SetBounds(int x, int y, int width, int height);
public void SetBounds(int x, int y, int width, int height);
member this.SetBounds : int * int * int * int -> unit
Public Sub SetBounds (x As Integer, y As Integer, width As Integer, height As Integer)

Parámetros

x
Int32

Left Nuevo valor de propiedad del control.

y
Int32

Top Nuevo valor de propiedad del control.

width
Int32

Width Nuevo valor de propiedad del control.

height
Int32

Height Nuevo valor de propiedad del control.

Consulte también

Se aplica a

SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified)

Establece los límites especificados del control en la ubicación y el tamaño especificados.

public:
 void SetBounds(int x, int y, int width, int height, System::Windows::Forms::BoundsSpecified specified);
public void SetBounds(int x, int y, int width, int height, System.Windows.Forms.BoundsSpecified specified);
member this.SetBounds : int * int * int * int * System.Windows.Forms.BoundsSpecified -> unit
Public Sub SetBounds (x As Integer, y As Integer, width As Integer, height As Integer, specified As BoundsSpecified)

Parámetros

x
Int32

Left Nuevo valor de propiedad del control.

y
Int32

Top Nuevo valor de propiedad del control.

width
Int32

Width Nuevo valor de propiedad del control.

height
Int32

Height Nuevo valor de propiedad del control.

specified
BoundsSpecified

Combinación bit a bit de los BoundsSpecified valores. Para cualquier parámetro no especificado, se usará el valor actual.

Ejemplos

En el ejemplo de código siguiente se centra un Form elemento en la pantalla del Layout evento . Esto mantendrá el formulario centrado a medida que el usuario lo cambia de tamaño. En este ejemplo se requiere que haya creado un Form control .

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

Consulte también

Se aplica a