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.
.net – Visual Studio- Hiding the Maximize Button in a Form
netvb.netvisual studiovisual studio 2010winforms
Related Topic
- Visual-studio – Cannot import the keyfile ‘blah.pfx’ – error ‘The keyfile may be password protected’
- Visual-studio – Difference between Build Solution, Rebuild Solution, and Clean Solution in Visual Studio
- .net – How to fix the Visual Studio compile error, “mismatch between processor architecture”
- Visual-studio – Error ‘LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt’ after installing Visual Studio 2012 Release Preview
- Visual-studio – Can you force Visual Studio to always run as an Administrator in Windows 8
- Asp.net-mvc – Visual Studio debugging/loading very slow
- Scala: list.flatten: no implicit argument matching parameter type (Any) = > Iterable[Any] was found
Best Answer
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 setSee update below.FormBorderStyle
set to theFixedToolWindow
orSizableToolWindow
, but then the form will not be displayed in the Windows task bar or in the ALT+TAB window.You can hide the entire
ControlBox
which will also removeMinimize
andClose
as well as the context menu.Pick your poison!
Update (12/24/15)
I decided to revisit the landscape with various options and it seems that:
FormBorderStyle
toFixedToolWindow/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).FormBorderStyle
toFixedDialog
also hides the maximize/minimize buttons and shows up in task bar, although the default icon is now lost (not sure why).MaximizeBox = False
does NOT hide the buttons, again contrary to the documentation. It simply disables it (and maximize functionality via toolbar double click).MaximizeBox = False
andMinimizeBox = False
hides them, irrespective ofFormBorderStyle
.Here are some screenshots:
Conclusion:
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.