Export (0) Print
Expand All
Expand Minimize

Control.SetBoundsCore Method

Performs the work of setting the specified bounds of this control.

[Visual Basic]
Protected Overridable Sub SetBoundsCore( _
   ByVal x As Integer, _
   ByVal y As Integer, _
   ByVal width As Integer, _
   ByVal height As Integer, _
   ByVal specified As BoundsSpecified _
)
[C#]
protected virtual void SetBoundsCore(
 int x,
 int y,
 int width,
 int height,
 BoundsSpecified specified
);
[C++]
protected: virtual void SetBoundsCore(
 int x,
 int y,
 int width,
 int height,
 BoundsSpecified specified
);
[JScript]
protected function SetBoundsCore(
   x : int,
 y : int,
 width : int,
 height : int,
 specified : BoundsSpecified
);

Parameters

x
The new Left property value of the control.
y
The new Top property value of the control.
width
The new Width property value of the control.
height
The new Height property value of the control.
specified
A bitwise combination of the BoundsSpecified values.

Remarks

Typically, the parameters that correspond to the bounds not included in the specified parameter are passed in with their current values. For example, the Height, Width, or the X or Y properties of the Location property can be passed in with a reference to the current instance of the control. However all values passed in are honored and applied to the control.

The boundsSpecified parameter represents the elements of the controls Bounds changed by your application. For example, if you change the Size of the control, the boundsSpecified parameter value is BoundsSpecified.Size. However, if the Size is adjusted in response to the Dock property being set, the boundsSpecified parameter value is BoundsSpecified.None.

Notes to Inheritors:  When overriding SetBoundsCore in a derived class, be sure to call the base class's SetBoundsCore method to force the bounds of the control to change. Derived classes can add size restrictions to the SetBoundsCore method.

Example

[Visual Basic, C#, C++] The following example overrides the SetBoundsCore method to ensure that the control remains a fixed size. This example assumes you have a class that is either directly or indirectly derived from the Control class.

[Visual Basic] 
Protected Overrides Sub SetBoundsCore(x As Integer, _
  y As Integer, width As Integer, _
  height As Integer, specified As BoundsSpecified)
   ' Set a fixed height and width for the control.
   MyBase.SetBoundsCore(x, y, 150, 75, specified)
End Sub

[C#] 
protected override void SetBoundsCore(int x, int y, 
   int width, int height, BoundsSpecified specified)
{
   // Set a fixed height and width for the control.
   base.SetBoundsCore(x, y, 150, 75, specified);
}

[C++] 
protected:
   void SetBoundsCore(int x, int y,
      int width, int height, BoundsSpecified specified) {
         // Set a fixed height and width for the control.
         UserControl::SetBoundsCore(x, y, 150, 75, specified);
      }

[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

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

See Also

Control Class | Control Members | System.Windows.Forms Namespace | SetBounds | Bounds | Layout

Show:
© 2014 Microsoft