语言

Control.SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) 方法

定义

执行设置此控件的指定边界的工作。

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

控件的新 Left 属性值。

y
Int32

控件的新 Top 属性值。

width
Int32

控件的新 Width 属性值。

height
Int32

控件的新 Height 属性值。

specified
BoundsSpecified

值的按位组合 BoundsSpecified 。

示例

下面的代码示例将重写 SetBoundsCore 该方法,以确保控件保持固定大小。 此示例要求你具有直接或间接派生自该类的 Control 类。

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 不包含的边界对应的参数会随其当前值一起传入。 例如,Height可以使用对控件的当前实例的引用传入属性或WidthX属性Y。 Location 但是,传入的所有值都遵循并应用于控件。

该 boundsSpecified 参数表示应用程序更改的控件 Bounds 的元素。 例如,如果更改 Size 控件,则 boundsSpecified 参数值是 Size 值 BoundsSpecified。 但是,如果SizeDock针对所设置的属性进行调整,则boundsSpecified参数值是None值 BoundsSpecified。

注释

在 Windows Server 2003 系统上,大小 Form 受监视器的最大像素宽度和高度的限制。

继承者说明

在派生类中重写 SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) 时,请务必调用基类 SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) 的方法以强制控件的边界更改。 派生类可以向 SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) 方法添加大小限制。

适用于

另请参阅