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

C#.NetWinformsSizeFixed

C# Problem Overview


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

C# Solutions


Solution 1 - C#

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();

Solution 2 - C#

Try to set

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

Solution 3 - C#

Minimal settings to prevent resize events

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

Solution 4 - C#

Properties -> FormBorderStyle -> FixedSingle

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

Solution 5 - C#

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.

Solution 6 - C#

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

Solution 7 - C#

Set the Maximise property to False.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionodisehView Question on Stackoverflow
Solution 1 - C#Pranay RanaView Answer on Stackoverflow
Solution 2 - C#user1700116View Answer on Stackoverflow
Solution 3 - C#Murilo PontesView Answer on Stackoverflow
Solution 4 - C#user3130990View Answer on Stackoverflow
Solution 5 - C#Paul MichaelsView Answer on Stackoverflow
Solution 6 - C#SercanView Answer on Stackoverflow
Solution 7 - C#Abhishek JaiswalView Answer on Stackoverflow