This documentation is archived and is not being maintained.

Form.MaximumSize Property

Gets the maximum size the form can be resized to.

[Visual Basic]
Public Property MaximumSize As Size
[C#]
public Size MaximumSize {get; set;}
[C++]
public: __property Size get_MaximumSize();
public: __property void set_MaximumSize(Size);
[JScript]
public function get MaximumSize() : Size;
public function set MaximumSize(Size);

Property Value

A Size that represents the maximum size for the form.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException The values of the height or width within the Size object are less than zero.

Remarks

This property enables you to limit the size of a form to a specified maximum size. You can use this feature when displaying multiple windows at the same time, to ensure that a single window does not cause other windows to be hidden. If this property is set to a Size object that is 0 in height and 0 in width, the form will have no maximum size beyond the limits set by Windows.

Example

[Visual Basic, C#] The following code example demonstrates setting the MaximumSize property.

[Visual Basic] 
Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Set the maximum size, so if user maximizes form, it 
    'will not cover entire desktop.  
    Me.MaximumSize = New Size(500, 500)


End Sub

[C#] 
public Form1() : base()
{        

    //This call is required by the Windows Form Designer.
    InitializeComponent();

    //Set the maximum size, so if user maximizes form, it 
    //will not cover entire desktop.  
    this.MaximumSize = new System.Drawing.Size(500, 500);


}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic 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

Form Class | Form Members | System.Windows.Forms Namespace | MaximizedBounds | MinimumSize | MaxWindowTrackSize

Show: