'Winforms - Disable that when user drags form by the border to move it, it resizes the form

I have a Winforms project with a form in it that is maximized (this.WindowState = System.Windows.Forms.FormWindowState.Maximized). When the user drags the form by its border to move the form around, it resizes to the size that I have set (which is not the maximum screen size since I do not know exactly to which values to set the MinimumSize property for it to be maximized on every screen).

I do not want this behaviour. I just want the form to stay maximized. I have set the FormBorderStyle to FixedDialog, so that the user can not resize the form by dragging the borders. I have tried to re-set the maximized window state in all kinds of events, but they do not seem to work.

Does anyone know how to fix this?



Solution 1:[1]

This might do the trick for you

this.MinimumSize = this.MaximumSize;
this.SizeGripStyle = SizeGripStyle.Hide;

and you can also try to write onResize event of the form

this.WindowState = System.Windows.Forms.FormWindowState.Maximized

Change the FormBorderStyle to one of the Fixed values: FixedSingle, Fixed3D, FixedDialog or FixedToolBar

// Define the border style of the form to a dialog box.
this.FormBorderStyle = FormBorderStyle.FixedDialog;

// Set the MaximizeBox to false to remove the maximize box.
this.MaximizeBox = false;

// Set the MinimizeBox to false to remove the minimize box.
this.MinimizeBox = false;

Solution 2:[2]

Have you tried

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

in combination with

this.WindowState = System.Windows.Forms.FormWindowState.Maximized

When you set this, you can't drag or resize the form.

However you will need to make your own close button or use "Alt+F4" to close the window.

Solution 3:[3]

Try setting the size, maximumsize and minimumsize to the same value.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Gwen Royakkers
Solution 3 Aninda Sen