How can I fix the form size in a C# Windows Forms application and not to let user change its size?
-
2Oh I got it By changing FormBorderStyle property of a form.... – odiseh May 26 '10 at 06:33
-
1dont forget to mark answer as accepted if it works for you.... – Pranay Rana Aug 02 '12 at 12:03
-
@odiseh I stumbled upon this and I see you still didn't accept an answer. please mask an answer as accepted - I'm sure there is a working solution provided in the answers – Breeze Jul 31 '15 at 12:21
7 Answers
Check this:
// Define the border style of the form to a dialog box.
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
// Set the MaximizeBox to false to remove the maximize box.
form1.MaximizeBox = false;
// Set the MinimizeBox to false to remove the minimize box.
form1.MinimizeBox = false;
// Set the start position of the form to the center of the screen.
form1.StartPosition = FormStartPosition.CenterScreen;
// Display the form as a modal dialog box.
form1.ShowDialog();

- 30,738
- 21
- 105
- 131

- 175,020
- 35
- 237
- 263
-
-
2I dont think this stops you from double clicking on the title bar and it full screens – Tizz Feb 16 '12 at 22:11
-
@Tizz I changed above things through designer, it worked.Double click didnt maximize it. I am using VS-2010 – prabhakaran Aug 28 '12 at 11:31
-
@Tizz is right, double clicking on the title bar still maximizes the form. I am using VS 2022 community edition. – Blue Phoenix Oct 30 '22 at 02:08
Try to set
this.MinimumSize = new Size(140, 480);
this.MaximumSize = new Size(140, 480);

- 51,061
- 28
- 99
- 211

- 191
- 1
- 3
Minimal settings to prevent resize events
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
form1.MaximizeBox = false;

- 161
- 1
- 4
Properties -> FormBorderStyle -> FixedSingle
if you can not find your Properties tool. Go to View -> Properties Window

- 101
- 1
- 2
I'm pretty sure this isn't the BEST way, but you could set the MinimumSize
and MaximimSize
properties to the same value. That will stop it.

- 30,738
- 21
- 105
- 131

- 16,185
- 43
- 146
- 269
After clicking on the form in the Design window, necessary changes can be made in the Properties window. To adjust the size of the form, the Width
and Height
fields of the Size
property are changed. In order to keep the size of the form constant, the value FixedSingle
is assigned to the FormBorderStyle
property.
In addition, you should prevent the screen from enlarging by editing the window style; the MaximizeBox
property must be set to false
.
When the form is run as a result of the changes made through the properties window, it remains fixed in size.

- 4,739
- 3
- 17
- 36
Set the Maximise property to False.

- 30,738
- 21
- 105
- 131

- 1,161
- 12
- 6
-
"the maximise property"? Do you mean "the `MaximizeBox` property"? – Peter Mortensen Mar 04 '18 at 22:19