51

How can I fix the form size in a C# Windows Forms application and not to let user change its size?

3
  • 2
    Oh I got it By changing FormBorderStyle property of a form....
    – odiseh
    May 26, 2010 at 6:33
  • 1
    dont forget to mark answer as accepted if it works for you.... Aug 2, 2012 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, 2015 at 12:21

7 Answers 7

84

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();
3
  • 2
    I dont think this stops you from double clicking on the title bar and it full screens
    – Tizz
    Feb 16, 2012 at 22:11
  • @Tizz I changed above things through designer, it worked.Double click didnt maximize it. I am using VS-2010 Aug 28, 2012 at 11:31
  • @Tizz is right, double clicking on the title bar still maximizes the form. I am using VS 2022 community edition. Oct 30, 2022 at 2:08
19

Try to set

this.MinimumSize = new Size(140, 480);
this.MaximumSize = new Size(140, 480);
12

Minimal settings to prevent resize events

form1.FormBorderStyle = FormBorderStyle.FixedDialog;
form1.MaximizeBox = false;
10

Properties -> FormBorderStyle -> FixedSingle

if you can not find your Properties tool. Go to View -> Properties Window

4

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.

1

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.

enter image description here

In addition, you should prevent the screen from enlarging by editing the window style; the MaximizeBox property must be set to false.

enter image description here

When the form is run as a result of the changes made through the properties window, it remains fixed in size.

enter image description here

0

Set the Maximise property to False.

1
  • "the maximise property"? Do you mean "the MaximizeBox property"? Mar 4, 2018 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.