-1

How can I disable the restore button in the control box of a windows form in c#. i need to make the form in maximized condition when it loads. is it possible? even the maximize box property is false, the restore box is shown automatically on the screen.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Roys
  • 1,596
  • 2
  • 13
  • 8
  • 3
    Set the ControlBox property MaximizeBox and MinimizedBox to false.? http://msdn.microsoft.com/en-us/library/system.windows.forms.form.controlbox.aspx – Philip Gullick Jul 25 '13 at 11:46
  • If you set `MaximizeBox` to false, the restore box will not appear. If that does not work for you, you will need to update your question with more information, like a [simple, self-contained example](http://sscce.org/). – Cody Gray - on strike Jul 25 '13 at 13:18

3 Answers3

3

So from my comment you do this:

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

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

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

This is from MSDN

To maximize your form you simply do this:

form1.WindowState = FormWindowState.Maximized;

Again this can be found on MSDN

Philip Gullick
  • 995
  • 7
  • 22
  • i have set the form properties as given below FormBorderStyle = FixedDialog; MaximizeBox = false; MinimizeBox = false; windowsState = Maximized; but its not working. the restore key appeared automatically. – Roys Jul 25 '13 at 12:48
  • @Roys - You will have to give me more than that for me to help you, What are you doing to get this problem? Where have you used this code? etc. – Philip Gullick Jul 25 '13 at 13:03
0

Have a look at this question: How do I remove minimize and maximize from a resizable window in WPF?

The first and most upvoted answer doesn't belong to WPF only. So it should also work with a Winforms application.

Community
  • 1
  • 1
netblognet
  • 1,951
  • 2
  • 20
  • 46
0

Set ResizeMode = CanMinimize and windowState = Maximized in the property panel.

croxy
  • 4,082
  • 9
  • 28
  • 46