274

How do I turn off the user's ability to resize a Windows Forms form?

I'm having it resize itself on a click.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ben Wilson
  • 3,057
  • 4
  • 21
  • 20
  • 53
    Set the FormBorderStyle to FixedSingle. – Hans Passant Nov 01 '11 at 17:24
  • 2
    possible duplicate of [How do I prevent a form from being resized by the user?](http://stackoverflow.com/questions/1119256/how-do-i-prevent-a-form-from-being-resized-by-the-user) – Ryan Gates Apr 25 '14 at 19:23
  • possible duplicate of [Prevent users from resizing the window/form size](http://stackoverflow.com/questions/1330339/prevent-users-from-resizing-the-window-form-size) – bluish Aug 25 '15 at 12:48

7 Answers7

452

Take a look at the FormBorderStyle property

form1.FormBorderStyle = FormBorderStyle.FixedSingle;

You may also want to remove the minimize and maximize buttons:

form1.MaximizeBox = false;
form1.MinimizeBox = false;
James Hill
  • 60,353
  • 20
  • 145
  • 161
  • 1
    Note that setting `MaximizeBox` to `false` is necessary to prevent the user from maximizing via `Windows key + up`. Setting `ControlBox` to `false` is not good enough. – David Sherret Feb 24 '20 at 22:24
88
  1. First, select the form.
  2. Then, go to the properties menu.
  3. And change the property "FormBorderStyle" from sizable to Fixed3D or FixedSingle.

    This is where to modify the property "FormBorderStyle".

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 2
    Perfect ... I put FormBorderStyle property to "FixedSingle" or "Fixed3D" and it is perfect. Users cannot resize the form anymore.. – Adam Tremblay Lavoie May 04 '16 at 00:11
  • This one actually stops users from resizing the screen. The accepted answer stops users from having a full screen button and a minimize button. – programmerRaj Mar 07 '20 at 14:59
20

More precisely, add the code below to the private void InitializeComponent() method of the Form class:

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
A-Sharabiani
  • 17,750
  • 17
  • 113
  • 128
4

Explanation

By default, FormBorderStyle property has the sizable value FormBorderStyle.Sizable assigned. Which enables form to be resized.

There are 7 kinds of FormBorderStyle property values available to use.

  • None
  • FixedSingle
  • Fixed3D
  • FixedDialog
  • Sizable
  • FixedToolWindow
  • SizableToolWindow

Depending upon the kind of form, we can assign the appropriate value accordingly. Assuming your form name is form1.

Choose any one from below to make it as Fixed

FixedSingle, Fixed3D, FixedDialog makes the form non-resizeable, assigning None will also work but won't make sense without a control box in case.

Code

Code snippets below, use any one of them

FixedSingle

    form1.FormBorderStyle = FormBorderStyle.FixedSingle;

Fixed3D

    form1.FormBorderStyle = FormBorderStyle.Fixed3D;

FixedDialog

    form1.FormBorderStyle = FormBorderStyle.FixedDialog;

None [Optional] Note: There'd no control box

    form1.FormBorderStyle = FormBorderStyle.None;

Or, Graphically

We can apply it graphically like this.

Make sure you've selected the form which you want to make it fixed size. then you'll see a property named FormBorderStyle property there in Properties window.

Graphical Properties window of Visual Studio IDE

dipakbari4
  • 840
  • 1
  • 12
  • 16
0

There is far more efficient answer: just put the following instructions in the Form_Load:

this.MinimumSize = new Size(Width, Height);
this.MaximumSize = this.MinimumSize;
i Mr Oli i
  • 605
  • 5
  • 12
0

Another way is to change properties "AutoSize" (set to True) and "AutosizeMode" (set to GrowAndShrink).

This has the effect of the form autosizing to the elements on it and never allowing the user to change its size.

chara
  • 73
  • 5
0

None of these answers worked for me, perhaps because my window had a status bar. To fix I did this:

StatusStripObject.SizingGrip = False

The same works for a StatusBar object, e.g.:

StatusBarObject.SizingGrip = False
Samuel
  • 8,063
  • 8
  • 45
  • 41