Control.SetClientSizeCore(Int32, Int32) 方法

定義

設定控制項工作區的大小。

protected:
 virtual void SetClientSizeCore(int x, int y);
protected virtual void SetClientSizeCore (int x, int y);
abstract member SetClientSizeCore : int * int -> unit
override this.SetClientSizeCore : int * int -> unit
Protected Overridable Sub SetClientSizeCore (x As Integer, y As Integer)

參數

x
Int32

工作區寬度 (單位為像素)。

y
Int32

工作區高度 (單位為像素)。

範例

下列程式碼範例會 SetClientSizeCore 覆寫 方法,以確保控制項維持正方形。 此範例會要求您有直接或間接衍生自 類別的 Control 類別。

protected:
   virtual void SetClientSizeCore( int x, int y ) override
   {
      // Keep the client size square.
      if ( x > y )
      {
         UserControl::SetClientSizeCore( x, x );
      }
      else
      {
         UserControl::SetClientSizeCore( y, y );
      }
   }
protected override void SetClientSizeCore(int x, int y)
{
   // Keep the client size square.
   if(x > y)
   {
      base.SetClientSizeCore(x, x);
   }
   else
   {
      base.SetClientSizeCore(y, y);
   }
}
Protected Overrides Sub SetClientSizeCore(x As Integer, y As Integer)
   ' Keep the client size square.
   If x > y Then
      MyBase.SetClientSizeCore(x, x)
   Else
      MyBase.SetClientSizeCore(y, y)
   End If
End Sub

備註

工作區從 (0、0) 位置開始,並延伸至 (xy) 位置。

一般而言,您不應該設定 ClientSize 控制項的 。

給繼承者的注意事項

在衍生類別中覆 SetClientSizeCore(Int32, Int32) 寫時,請務必呼叫基類 SetClientSizeCore(Int32, Int32) 的 方法, ClientSize 以便調整 屬性。

如需在控制項上繪製的詳細資訊,請參閱轉譯Windows Forms控制項

適用於

另請參閱