Back to my subject:
I am currently working on a dialog that asks you are you sure you want to leave. I have this so far and it works perfectly when I have it as a EventArgs. When I link it to something like Exit in the file menu. Though when it comes to the events in the app itself where the "Form Closing" is on Visual Studios it seems to act wired. Like if you pushed "Yes" it brings up the dialog again and asks you the same question. Then it shuts down. Or if you are "Not Sure" it closes the application right away.
Here is the code for the "File" menu
Expand|Select|Wrap|Line Numbers
- private void Exit(object sender, System.EventArgs e)
- {
- DialogResult dr = System.Windows.Forms.MessageBox.Show("Are You Sure You Want To Exit?", "Exit?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (dr == DialogResult.Yes)
- {
- //close the program
- Application.Exit();
- }
- else
- {
- //Cancel
- }
- }
Can anyone help me?