This documentation is archived and is not being maintained.

Control.Size Property

Gets or sets the height and width of the control.

[Visual Basic]
Public Property Size As Size
public Size Size {get; set;}
public: __property Size get_Size();
public: __property void set_Size(Size);
public function get Size() : Size;
public function set Size(Size);

Property Value

The Size object that represents the height and width of the control in pixels.


Because the Size class is a value type (Structure in Visual Basic, struct in C#), it is returned by value, meaning accessing the property returns a copy of the size of the control. So, adjusting the Width or Height properties of the Size object returned from this property will not affect the Width or Height of the control. To adjust the Width or Height of the control, you must set the control's Width or Height property, or set the Size property with a new Size object.

Note   In order to maintain better performance, you should not set the Size of a control in its constructor. The preferred method is to override the DefaultSize property.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Control Class | Control Members | System.Windows.Forms Namespace | SetBounds