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

定义

执行设置该控件的指定边界的工作。Performs the work of setting the specified bounds of this control.

protected:
 virtual void SetBoundsCore(int x, int y, int width, int height, System::Windows::Forms::BoundsSpecified specified);
protected virtual void SetBoundsCore (int x, int y, int width, int height, System.Windows.Forms.BoundsSpecified specified);
abstract member SetBoundsCore : int * int * int * int * System.Windows.Forms.BoundsSpecified -> unit
override this.SetBoundsCore : int * int * int * int * System.Windows.Forms.BoundsSpecified -> unit
Protected Overridable Sub SetBoundsCore (x As Integer, y As Integer, width As Integer, height As Integer, specified As BoundsSpecified)

参数

x
Int32 Int32 Int32 Int32

控件的新 Left 属性值。The new Left property value of the control.

y
Int32 Int32 Int32 Int32

控件的新 Top 属性值。The new Top property value of the control.

width
Int32 Int32 Int32 Int32

控件的新 Width 属性值。The new Width property value of the control.

height
Int32 Int32 Int32 Int32

控件的新 Height 属性值。The new Height property value of the control.

specified
BoundsSpecified BoundsSpecified BoundsSpecified BoundsSpecified

BoundsSpecified 值的按位组合。A bitwise combination of the BoundsSpecified values.

示例

下面的代码示例重写SetBoundsCore方法,以确保控件保持固定大小。The following code example overrides the SetBoundsCore method to ensure that the control remains a fixed size. 此示例要求具有直接或间接从Control类派生的类。This example requires that you have a class that is either directly or indirectly derived from the Control class.

protected:
   virtual void SetBoundsCore( int x, int y, int width, int height, BoundsSpecified specified ) override
   {
      // Set a fixed height and width for the control.
      UserControl::SetBoundsCore( x, y, 150, 75, specified );
   }
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);
}
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

注解

通常,与specified参数中未包含的界限相对应的参数将与当前值一起传入。Typically, the parameters that correspond to the bounds not included in the specified parameter are passed in with their current values. 例如Height,可以将Y Width属性Location的、或X属性与控件的当前实例的引用一起传入。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.

参数表示由您的应用程序更改Bounds的控件的元素。 boundsSpecifiedThe boundsSpecified parameter represents the elements of the controls Bounds changed by your application. 例如Size ,如果更改控件的boundsSpecified ,则参数值为SizeBoundsSpecified值。For example, if you change the Size of the control, the boundsSpecified parameter value is the Size value of BoundsSpecified. 但是, Size如果在响应所设置的boundsSpecified Dock属性时调整,则参数值为NoneBoundsSpecified值。However, if the Size is adjusted in response to the Dock property being set, the boundsSpecified parameter value is the None value of BoundsSpecified.

备注

在 Windows Server 2003 系统上,的大小Form受监视器的最大像素宽度和高度的限制。On Windows Server 2003 systems, the size of a Form is restricted by the maximum pixel width and height of the monitor.

继承者说明

当在SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)派生类中重写时,请确保调用基类的SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)方法来强制更改控件边界。When overriding SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) in a derived class, be sure to call the base class's SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) method to force the bounds of the control to change. 派生类可以向SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)方法添加大小限制。Derived classes can add size restrictions to the SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) method.

适用于

另请参阅