Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.5 C# Windows
Hello,
 
I want to show only minimize option in my c# .net windows application.
close button should not disable or enable,it should be hide.
Minimize button should be show only.
 
How it can be possible?
 
Thanks
 
Ankit Agarwal
Software Engineer
Posted 27-Jun-13 21:19pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can't.
The best you can do is disable the Close button, and it alone: Disable the Close box on a form[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I had the similar problem.
 
You can remove the entire control box (Maximum, Minimum and Close buttons).
Then add a button at the top right of the dialog which looks like Minimize button.
 
Add Minimize button functionality to that button.
 
Following could be the UI code for that:
 
<DockPanel LastChildFill="True">
        <DockPanel VerticalAlignment="Center" DockPanel.Dock="Top">
            <Button  DockPanel.Dock="Right" Content="-" Width="20" Height="20" Margin="5,5,5,5" FontSize="15" HorizontalAlignment="Right"/>
        </DockPanel>
 
searchDialogWindow.ResizeMode = ResizeMode.CanMinimize;
            searchDialogWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            searchDialogWindow.WindowStyle = WindowStyle.None;
 
However, one drawback of this could be you cannot drag the dialog..
 
Other solution I thought is putting a method in closing event and close the window only in certain condition minimize other conditions.
 
searchDialogWindow.Closing += SearchDialogWindowOnClosing;
 
private void SearchDialogWindowOnClosing(object sender, CancelEventArgs cancelEventArgs)
       {
           searchDialogWindow.WindowState = WindowState.Minimized;
           cancelEventArgs.Cancel = isSearchInProgress;
       }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

If you are using WinForms you could try this:
 
1) Disable the form's maximize button (set it's MaximizeBox property to false), and let it show the minimize and close boxes.
 
2) Add one variable (initialized to false) similar to
bool m_IDoWantToClose;
 
3) In the button (I suppose that's your case) where you want to make the form close add code to set the m_IDoWantToClose variable to true just before calling the form's Close() method.
 
4) Add one event handler for the form's FormClosing event so you can cancel the form closing when the variable m_IDoWantToClose is not set to true. For that you can set to true the property e.Cancel of the method's e argument (of type FormClosingEventArgs).
 
The 'Close' button box will be shown, but will not close the form.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,327
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,920


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 17 Sep 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100