Control.SetClientSizeCore(Int32, Int32) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
设置控件的工作区的大小。
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) 位置开始,并扩展到 (x, y) 位置。
通常,不应设置 ClientSize 控件。
继承者说明
在派生类中重写 SetClientSizeCore(Int32, Int32) 时,请务必调用基类 SetClientSizeCore(Int32, Int32) 的方法,以便 ClientSize 调整属性。
有关在控件上绘图的详细信息,请参阅 呈现 Windows 窗体控件。