Reputation: 3240
I only want to display the Minimize and Close buttons on the caption bar, without the Maximize button using C#.net in WinForm Application. If I put this.MaximizeBox = false, the Maximize button is still displayed although it will be disabled. Any help will be appreciated. Please Provide me your excellent ideas
Thanks in Advance.
Upvotes: 0
Views: 7133
Reputation: 11
If you don't mind losing the minimize button, you could use the forms FormBorderStyle to FixedToolWindow or SizableToolWindow. There are some side effects to this approach though (from MSDN):
FixedToolWindow: A tool window border that is not resizable. A tool window does not appear in the taskbar or in the window that appears when the user presses ALT+TAB. Although forms that specify FixedToolWindow typically are not shown in the taskbar, you must also ensure that the ShowInTaskbar property is set to false, since its default value is true.
SizableToolWindow: A resizable tool window border. A tool window does not appear in the taskbar or in the window that appears when the user presses ALT+TAB.
You could set the control box property on the form to false (but then you lose the close button as well as the minimize button).
It looks like you should also be able to use the windows API (in this link the guy is hiding the close button for a wpf app, but I would think you could repurpose it) http://winsharp93.wordpress.com/2009/07/21/wpf-hide-the-window-buttons-minimize-restore-and-close-and-the-icon-of-a-window/
Upvotes: 0
Reputation: 19842
What you need to do is paint your own window chrome. See this SO question for how to do so:
Custom titlebars/chrome in a WinForms app
Upvotes: 2