| View previous topic :: View next topic |
| Author |
Message |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Tue Feb 12, 2008 1:20 pm Post subject: [HELP C#] how do i disable the (X) button |
|
|
how can i disable the exit button (X) in my form ?
i know that for maximize is this.maximizebox = false;
what is the command for exit button?
_________________
Stylo |
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Tue Feb 12, 2008 1:36 pm Post subject: |
|
|
nice thx
btw how do make that if i'll press Yes on YesNo messagebox then it'll close my form?
_________________
Stylo |
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Tue Feb 12, 2008 3:25 pm Post subject: |
|
|
Use the FormClosing event, I think
_________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Feb 12, 2008 3:28 pm Post subject: |
|
|
FormClosing/Button (if you disable ControlBox) Event:
DialogResult dr = MessageBox.Show( "Are You Sure You Want to Exit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
if ( dr == DialogResult.Yes )
Close();
// if your doing FormClosing Event then you'll have to add this
else if ( dr == DialogResult.No )
e.Cancel();
if u want you can change it to MessageBoxButtons.YesNoCancel and then do
if ( dr == DialogResult.Cancel )
e.Cancel();
Usually you only use the cancel button if your closing statement is like "would you like to save before closing" then yes would save then close, no would just close, and cancel would cancel.
( e is defined in the Event function )
Also if u dont want the x box's to start just go into the form property, go to near the bottom and select ControlBox then set it to false. (better then calling it in Form1_Load
_________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Tue Feb 12, 2008 4:05 pm Post subject: |
|
|
this.ControlBox = false?
Though this disables all the buttons... you can do e.Cancel on FormClosing aswell.
|
|
| Back to top |
|
 |
|