Control.SetClientSizeCore(Int32, Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the size of the client area of the control.
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)
Parameters
- x
- Int32
The client area width, in pixels.
- y
- Int32
The client area height, in pixels.
Examples
The following code example overrides the SetClientSizeCore method to ensure that the control remains square. This example requires that you have a class that is either directly or indirectly derived from the Control class.
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
Remarks
The client area starts at the (0, 0) location and extends to the (x
, y
) location.
Typically, you should not set the ClientSize of the control.
Notes to Inheritors
When overriding SetClientSizeCore(Int32, Int32) in a derived class, be sure to call the base class's SetClientSizeCore(Int32, Int32) method so that the ClientSize property is adjusted.
For more information about drawing on controls, see Rendering a Windows Forms Control.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기