Control.SetBounds Method (Int32, Int32, Int32, Int32, BoundsSpecified)

Sets the specified bounds of the control to the specified location and size.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

Public Sub SetBounds ( _
	x As Integer, _
	y As Integer, _
	width As Integer, _
	height As Integer, _
	specified As BoundsSpecified _
Dim instance As Control
Dim x As Integer
Dim y As Integer
Dim width As Integer
Dim height As Integer
Dim specified As BoundsSpecified

instance.SetBounds(x, y, width, height, specified)
public void SetBounds (
	int x, 
	int y, 
	int width, 
	int height, 
	BoundsSpecified specified
public function SetBounds (
	x : int, 
	y : int, 
	width : int, 
	height : int, 
	specified : BoundsSpecified



The new Left property value of the control.


The new Top property value of the control.


The new Width property value of the control.


The new Height property value of the control.


A bitwise combination of the BoundsSpecified values. For any parameter not specified, the current value will be used.

The following code example centers a Form on the screen in the Layout event. This will keep the form centered as the user resizes it. This example requires that you have created a Form control.

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions