This documentation is archived and is not being maintained.

Control.DefaultSize Property

Gets the default size of the control.

[Visual Basic]
Protected Overridable ReadOnly Property DefaultSize As Size
protected virtual Size DefaultSize {get;}
protected: __property virtual Size get_DefaultSize();
protected function get DefaultSize() : Size;

Property Value

The default Size of the control.


The DefaultSize property represents the Size of the control when it is initially created. You can adjust the size of the control by setting its Size property value.

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.

Notes to Inheritors:  When overriding the DefaultSize property in a derived class, it is preferable return a Size object with the desired dimensions rather than overriding all the implementation.


[Visual Basic, C#, C++] The following example overrides the DefaultSize property, and makes the default size of the form 500 pixels square.

[Visual Basic] 
Protected Overrides ReadOnly Property DefaultSize() As Size
      ' Set the default size of
      ' the form to 500 pixels square. 
      Return New Size(500, 500)
   End Get
End Property

protected override Size DefaultSize
      // Set the default size of
      // the form to 500 pixels square.
      return new Size(500,500);

    __property System::Drawing::Size get_DefaultSize() {

        // Set the default size of
        // the form to 500 pixels square.
        return System::Drawing::Size(500, 500);


[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


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

See Also

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