How can I fix the form size in a C# Windows Forms application and not to let user change its size?
121,744
Solution 1
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
Try to set
this.MinimumSize = new Size(140, 480);
this.MaximumSize = new Size(140, 480);
Solution 3
Minimal settings to prevent resize events
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
form1.MaximizeBox = false;
Solution 4
Properties -> FormBorderStyle -> FixedSingle
if you can not find your Properties tool. Go to View -> Properties Window
Solution 5
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.
Related videos on Youtube
Author by
odiseh
Updated on July 09, 2022Comments
-
odiseh almost 2 years
How can I fix the form size in a C# Windows Forms application and not to let user change its size?
-
odiseh almost 14 yearsOh I got it By changing FormBorderStyle property of a form....
-
Pranay Rana almost 12 yearsdont forget to mark answer as accepted if it works for you....
-
Breeze almost 9 years@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
-
-
Nano HE over 12 yearsIt's great help to me. Thanks.
-
Tizz about 12 yearsI dont think this stops you from double clicking on the title bar and it full screens
-
prabhakaran over 11 years@Tizz I changed above things through designer, it worked.Double click didnt maximize it. I am using VS-2010
-
Peter Mortensen about 6 years"the maximise property"? Do you mean "the
MaximizeBox
property"?