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

定義

執行設定這個控制項的指定範圍的工作。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

控制項的新 Left 屬性值。The new Left property value of the control.

y
Int32

控制項的新 Top 屬性值。The new Top property value of the control.

width
Int32

控制項的新 Width 屬性值。The new Width property value of the control.

height
Int32

控制項的新 Height 屬性值。The new Height property value of the control.

specified
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. 例如,您可以使用控制項目前實例的參考,傳入 Location 屬性的 HeightWidthXY 屬性。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.

boundsSpecified 參數代表應用程式 Bounds 變更之控制項的元素。The boundsSpecified parameter represents the elements of the controls Bounds changed by your application. 例如,如果您變更控制項的 SizeboundsSpecified 參數值就是 BoundsSpecifiedSize 值。For example, if you change the Size of the control, the boundsSpecified parameter value is the Size value of BoundsSpecified. 不過,如果調整 Size 以回應所設定的 Dock 屬性,則 boundsSpecified 參數值為 BoundsSpecifiedNone 值。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.

適用於

另請參閱