Coder Perfect

A Windows Forms form can’t be resized.


How can I prevent a user from resizing a Windows Forms form?

On a click, I’m having it enlarge itself.

Asked by Ben Wilson

Solution #1

Examine the FormBorderStyle property.

form1.FormBorderStyle = FormBorderStyle.FixedSingle;

It’s also a good idea to get rid of the reduce and maximum buttons:

form1.MaximizeBox = false;
form1.MinimizeBox = false;

Answered by James Hill

Solution #2

Answered by Mahmoud Maghrabi

Solution #3

To be more specific, add the following code to the Form class’s private void InitializeComponent() method:

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;

Answered by A-Sharabiani

Solution #4

FormBorderStyle is the default value for the FormBorderStyle property. A sizable task has been allocated. This allows the form to be resized.

FormBorderStyle property values can be used in seven different ways.

We can assign the proper value to the form depending on its kind. Assume the name of your form is form1.

Choose one of the options below to set it as Fixed.

FixedSingle, Fixed3D, and FixedDialog make the form non-resizeable; assigning None will also work, but without a control box, it won’t make sense.

Use any of the code snippets below.

    form1.FormBorderStyle = FormBorderStyle.FixedSingle;
    form1.FormBorderStyle = FormBorderStyle.Fixed3D;
    form1.FormBorderStyle = FormBorderStyle.FixedDialog;
    form1.FormBorderStyle = FormBorderStyle.None;

This is how we can use it graphically.

Make sure you’ve chosen the form you’d like to make fixed size. Then, in the Properties pane, you’ll find a property called FormBorderStyle.

Answered by dipakbari4

Solution #5

Another option is to adjust the “AutoSize” (True) and “AutosizeMode” attributes (set to GrowAndShrink).

This causes the form to auto-scale to the elements on it, with the user never being able to adjust its size.

Answered by chara

Post is based on