How do I disable form resizing for users?

C#FormsWinformsResize

C# Problem Overview


How do I disable form resizing for users? Which property is used?

I tried AutoSize and AutoSizeMode.

C# Solutions


Solution 1 - C#

Change the FormBorderStyle to one of the fixed values: FixedSingle, Fixed3D, FixedDialog or FixedToolWindow.

The FormBorderStyle property is under the Appearance category.

Or 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#

Use the FormBorderStyle property. Make it FixedSingle:

this.FormBorderStyle = FormBorderStyle.FixedSingle;

Solution 3 - C#

Use the FormBorderStyle property of your Form:

this.FormBorderStyle = FormBorderStyle.FixedDialog;

Solution 4 - C#

Change this property and try this at design time:

FormBorderStyle = FormBorderStyle.FixedDialog;

Designer view before the change:

Enter image description here

Solution 5 - C#

I always use this:

// Lock form
this.MaximumSize = this.Size;
this.MinimumSize = this.Size;

This way you can always resize the form from Designer without changing code.

Solution 6 - C#

Using the MaximumSize and MinimumSize properties of the form will fix the form size, and prevent the user from resizing the form, while keeping the form default FormBorderStyle.

this.MaximumSize = new Size(XX, YY);
this.MinimumSize = new Size(X, Y);

Solution 7 - C#

I would set the maximum size, minimum size and remove the gripper icon of the window.

Set properties (MaximumSize, MinimumSize, and SizeGripStyle):

this.MaximumSize = new System.Drawing.Size(500, 550);
this.MinimumSize = new System.Drawing.Size(500, 550);
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;

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
QuestionDianaView Question on Stackoverflow
Solution 1 - C#Pranay RanaView Answer on Stackoverflow
Solution 2 - C#Sangram NandkhileView Answer on Stackoverflow
Solution 3 - C#Javed AkramView Answer on Stackoverflow
Solution 4 - C#Amit JesaniView Answer on Stackoverflow
Solution 5 - C#LaurconsView Answer on Stackoverflow
Solution 6 - C#Alex JoligView Answer on Stackoverflow
Solution 7 - C#César LeónView Answer on Stackoverflow