Export (0) Print
Expand All
Expand Minimize

BoundsSpecified Enumeration

Specifies the bounds of the control to use when defining a control's size and position.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

[Visual Basic]
<Flags>
<Serializable>
Public Enum BoundsSpecified
[C#]
[Flags]
[Serializable]
public enum BoundsSpecified
[C++]
[Flags]
[Serializable]
__value public enum BoundsSpecified
[JScript]
public
   Flags
 Serializable
enum BoundsSpecified

Remarks

Use the members of this enumeration when calling the SetBoundsCore and SetBounds methods of the Control class.

Members

Member name Description Value
All Both Location and Size property values are defined. 15
Height The height of the control is defined. 8
Location Both X and Y coordinates of the control are defined. 3
None No bounds are specified. 0
Size Both Width and Height property values of the control are defined. 12
Width The width of the control is defined. 4
X The left edge of the control is defined. 1
Y The top edge of the control is defined. 2

Example

[Visual Basic] 

    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

[C#] 
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);    
}

[C++] 
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);    
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Windows.Forms

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Windows.Forms (in System.Windows.Forms.dll)

See Also

System.Windows.Forms Namespace | SetBoundsCore | SetBounds | Size | Location

Show:
© 2014 Microsoft