Gets or sets the height and width of the client area of the control.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The client area of a control is the bounds of the control, minus the nonclient elements such as scroll bars, borders, title bars, and menus. The SetClientSizeCore method is called to set the property. The property is not always changed through its set method so you should override the SetClientSizeCore method to ensure that your code is executed when the property is set.
The Size.Width and Size.Height properties represent the width and height of the client area of the control. You can use this property to obtain the size of the client area of the control for tasks such as drawing on the surface of the control.
For more information about drawing on controls, see Rendering a Windows Forms Control.
You cannot bind application settings to this property. For more information on application settings, see Application Settings Overview.
The following code example resizes the specified control so the control will accommodate its formatted text. The formatted text is the Text property with the control's assigned Font applied to the text. The AutoSizeControl method in this example also has a textPadding parameter that represents the padding to apply to all edges of the control. To make the padding appear equal, align the text with the ContentAlignment.MiddleCenter value, if your control supports it.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.