How to Stop the Form from Closing...
-
Is there a way to stop the form from closing within its
OnClosing
event? I'm making a program that asks if you really want to close it when you press the "x". So I've got a dialog that pops up and conditional statements for whichever button is pressed in the dialog, but I'm not sure what to put in the conditional statements to make the form stop closing. Could anyone help me out with this?
If I had a sig, it would probably go here.
-
Is there a way to stop the form from closing within its
OnClosing
event? I'm making a program that asks if you really want to close it when you press the "x". So I've got a dialog that pops up and conditional statements for whichever button is pressed in the dialog, but I'm not sure what to put in the conditional statements to make the form stop closing. Could anyone help me out with this?
If I had a sig, it would probably go here.
Yep:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{DialogResult result = MessageBox.Show("Are you sure you wish to cancel?", "Cancel?", MessageBoxButtons.YesNo); if (result == DialogResult.No) { e.Cancel = true; }
}
"It was the day before today.... I remember it like it was yesterday." -Moleman
-
Is there a way to stop the form from closing within its
OnClosing
event? I'm making a program that asks if you really want to close it when you press the "x". So I've got a dialog that pops up and conditional statements for whichever button is pressed in the dialog, but I'm not sure what to put in the conditional statements to make the form stop closing. Could anyone help me out with this?
If I had a sig, it would probably go here.
yes, see martin's reply. Thats exactly why the Closing event exists, so you can prevent a Closed event from happening. :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
yes, see martin's reply. Thats exactly why the Closing event exists, so you can prevent a Closed event from happening. :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
You're welcome.
max29297 wrote:
If I had a sig, it would probably go here
You probably mean: I'm happy I dont need a sig anymore...
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
You're welcome.
max29297 wrote:
If I had a sig, it would probably go here
You probably mean: I'm happy I dont need a sig anymore...
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }