Export (0) Print
Expand All
Expand Minimize

Control.DefaultSize Property

Gets the default size of the control.

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

Property Value

The default Size of the control.

Remarks

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.

Example

[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
   Get
      ' Set the default size of
      ' the form to 500 pixels square. 
      Return New Size(500, 500)
   End Get
End Property

[C#] 
protected override Size DefaultSize
{
   get
   {
      // Set the default size of
      // the form to 500 pixels square.
      return new Size(500,500);
   }
}

[C++] 
protected:
    __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.

Requirements

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

Show:
© 2015 Microsoft