How do I turn off the user\'s ability to resize a Windows Forms form?
I\'m having it resize itself on a click.
Take a look at the FormBorderStyle property
form1.FormBorderStyle = FormBorderStyle.FixedSingle;
You may also want to remove the minimize and maximize buttons:
form1.MaximizeBox = false;
form1.MinimizeBox = false;
There is far more efficient answer: just put the following instructions in the Form_Load
:
Me.MinimumSize = New Size(Width, Height)
Me.MaximumSize = Me.MinimumSize
More precisely, add the code below to the private void InitializeComponent()
method of the Form class:
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
Another way is to change properties "AutoSize" (set to True) and "AutosizeMode" (set to GrowAndShrink).
This has the effect of the form autosizing to the elements on it and never allowing the user to change its size.
And change the property "FormBorderStyle" from sizable to Fixed3D or FixedSingle.