Visual Studio- Hiding the Maximize Button in a Form
How do I remove the maximize button from a form? I've already disabled it but it still shows up, it just doesn't work. I want a form with only the close and minimize buttons. It's a Windows Form Application and I'm using Visual Studio 2010.
Hiding the maximize button is not possible without you painting your own window frame.
Having it disabled tells the user that he can't maximize the form which is good UX. Hiding it doesn't help because double clicking the title bar will still maximize the window (if you haven't disabled Maximize).
You can set FormBorderStyle set to the FixedToolWindow or SizableToolWindow, but then the form will not be displayed in the Windows task bar or in the ALT+TAB window. See update below.
You can hide the entire ControlBox which will also remove Minimize and Close as well as the context menu.
Pick your poison!
I decided to revisit the landscape with various options and it seems that:
- contrary to what documentation says, setting FormBorderStyle to FixedToolWindow/SizableToolWindow no longer hides the app in task bar or ALT+TAB window in Windows 7 and up. ShowInTaskbar exclusively decides Show/Hide effect in this case (thanks to @pinowthebird for nudging me to take a re-look).
- Setting FormBorderStyle to FixedDialog also hides the maximize/minimize buttons and shows up in task bar, although the default icon is now lost (not sure why).
- Setting MaximizeBox = False does NOT hide the buttons, again contrary to the documentation. It simply disables it (and maximize functionality via toolbar double click).
- Setting both MaximizeBox = False and MinimizeBox = False hides them, irrespective of FormBorderStyle.
Here are some screenshots:
Based on your requirements, you can either opt for 1, 2 or 3. Hope this helps future visitors.
Disclaimer: These tests were done in VS 2015, .Net 4.6 and a brand new WinForm app. The documentation says that these properties were available since .Net 1.1. However, as you can see in the screenshots - take the documentation with a grain of salt! Also the OS plays a vital role in the outcome.
it is simple :) do this
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MaximizeBox = False End Sub
Now, your client can't maximize your form, even if he/she double clicks the title bar of your form.
You can change the properties of FormBorderStyle to FixedToolWindows or SizableToolWindow.
Just set the property "MaximiseBox" to be false in the properties window of the form. The same goes for the minimize box as well.
If you set ControlBox to False, you will lose the Minimize, Maximize, and Close buttons in the upper right corner. The ControlBox is the object housing the Context menu in the upper left of your form.
If you leave ControlBox set to True, you must set both Maximize and Minimize to False - this hides both buttons. Without possibly p/invoking Win32, I don't believe your control gets any more granular than that.
Private Sub Form4_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize If Me.WindowState = FormWindowState.Minimized Then Me.WindowState = FormWindowState.Normal End If End Sub
In Visual Studio, First Select the Form, go to the properties and Click on Maximize Box , set it to False.It will hide the Maximize Button.
We can disable the two icon, minimize and maximize. You will have to set the "minimize and maximize icon as false both. If either icon remains true, then all three icon will be display on your form window.