Home:ALL Converter>Disabling Minimize & Maximize On WinForm?

Disabling Minimize & Maximize On WinForm?

Ask Time:2010-06-12T04:15:54         Author:sooprise

Json Formatter

WinForms have those three boxes in the upper right hand corner that minimize, maximize, and close the form. What I want to be able to do is to remove the minimize and maximize, while keeping the close.

I also what to make the close minimize the form instead of closing it.

How can this be done?

Author:sooprise,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/3025923/disabling-minimize-maximize-on-winform
unofficialdxnny :

In the form editor select the main form right-click -> properties\nScroll all the way down, find the MinimiseBox turn to False than same with MaximiseBox if you dont want.\n\nIn my case i have just disabled the MaximiseBox to False",
2022-07-04T19:10:18
Hans Olsson :

The Form has two properties called MinimizeBox and MaximizeBox, set both of them to false. \n\nTo stop the form closing, handle the FormClosing event, and set e.Cancel = true; in there and after that, set WindowState = FormWindowState.Minimized;, to minimize the form.",
2010-06-11T20:19:48
volody :

Set MaximizeBox and MinimizeBox form properties to False",
2010-06-11T20:18:13
dlras2 :

Bind a handler to the FormClosing event, then set e.Cancel = true, and set the form this.WindowState = FormWindowState.Minimized.\n\nIf you want to ever actually close the form, make a class-wide boolean _close and, in your handler, set e.Cancel to !_close, so that whenever the user clicks the X on the window, it doesn't close, but you can still close it (without just killing it) with close = true; this.Close();\n\n(And just to make my answer complete) set MaximizeBox and MinimizeBox form properties to False.",
2010-06-11T20:20:26
Arunkumar Pushparaj :

Right Click the form you want to hide them on, choose Controls -> Properties.\n\nIn Properties, set \n\n\nControl Box -> False\nMinimize Box -> False\nMaximize Box -> False\n\n\nYou'll do this in the designer.",
2014-10-24T12:23:36
Brackets :

How to make form minimize when closing was already answered, but how to remove the minimize and maximize buttons wasn't.\nFormBorderStyle: FixedDialog\nMinimizeBox: false\nMaximizeBox: false",
2017-07-27T06:05:41
Sameera R. :

you can simply disable maximize inside form constructor.\n\n public Form1(){\n InitializeComponent();\n MaximizeBox = false;\n }\n\n\nto minimize when closing.\n\nprivate void Form1_FormClosing(Object sender, FormClosingEventArgs e) {\n e.Cancel = true;\n WindowState = FormWindowState.Minimized;\n}\n",
2013-12-17T10:32:39
Mauricio Kenny :

public Form1()\n{\nInitializeComponent();\n//this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;\nthis.MaximizeBox = false;\nthis.MinimizeBox = false;\n}\n",
2019-03-28T08:45:19
yy