119

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?

9 Answers 9

188

The Form has two properties called MinimizeBox and MaximizeBox, set both of them to false.

To 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.

2
  • 1
    Could you not just set control box to false. Commented Mar 18, 2015 at 9:03
  • 3
    @krystanhonour The OP wanted to keep the close though. Commented Mar 19, 2015 at 10:28
21

Set MaximizeBox and MinimizeBox form properties to False

17

Bind a handler to the FormClosing event, then set e.Cancel = true, and set the form this.WindowState = FormWindowState.Minimized.

If 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();

(And just to make my answer complete) set MaximizeBox and MinimizeBox form properties to False.

12

Right Click the form you want to hide them on, choose Controls -> Properties.

In Properties, set

  • Control Box -> False
  • Minimize Box -> False
  • Maximize Box -> False

You'll do this in the designer.

0
6

How to make form minimize when closing was already answered, but how to remove the minimize and maximize buttons wasn't.
FormBorderStyle: FixedDialog
MinimizeBox: false
MaximizeBox: false

3

you can simply disable maximize inside form constructor.

 public Form1(){
     InitializeComponent();
     MaximizeBox = false;
 }

to minimize when closing.

private void Form1_FormClosing(Object sender, FormClosingEventArgs e) {
    e.Cancel = true;
    WindowState = FormWindowState.Minimized;
}
2

In the form editor select the main form right-click -> properties

Scroll all the way down, find the MinimiseBox turn to False than same with MaximiseBox if you dont want.

Image

In my case i have just disabled the MaximiseBox to False

2

This works for me if you want no border and no maximize (including disable double click maximize over the form) nor minimize:

public Form1()
{
    InitializeComponent();
    this.MaximizeBox = false;
    this.ControlBox = false;
    this.FormBorderStyle = FormBorderStyle.FixedSingle;
    this.Text = string.Empty;
}
0
public Form1()
{
InitializeComponent();
//this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
}
3
  • 3
    Please add some explanation to your answer
    – mechnicov
    Commented Mar 28, 2019 at 9:05
  • My friend, it's very easy, only must to read each line of code Commented Apr 12, 2019 at 18:08
  • On SO it's low quality answer
    – mechnicov
    Commented Apr 12, 2019 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.