why does my dialog act wired when closing the app?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ajm113
    New Member
    • Jun 2007
    • 161

    why does my dialog act wired when closing the app?

    Ok, first off I like to say hi and I am a developer of the Doom3 Scripter project and I wanted to go with C# and Visual Studios for the 2.0 area and I needed some help with both of those things.

    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
    Code:
            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
                }
            }
    Its pretty much the same for the FormClosingEven tArgs in the private void area that I use.

    Can anyone help me?
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by Ajm113
    Ok, first off I like to say hi and I am a developer of the Doom3 Scripter project and I wanted to go with C# and Visual Studios for the 2.0 area and I needed some help with both of those things.

    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
    Code:
            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
                }
            }
    Its pretty much the same for the FormClosingEven tArgs in the private void area that I use.

    Can anyone help me?
    Hello, Ajm113!

    I am now getting my feet wet in C#, but it looks like you are not tell the program what to do in order to cancel. May be the reason why you are going in a loop with this...

    Comment

    • Ajm113
      New Member
      • Jun 2007
      • 161

      #3
      What do I use to close the dialog then and cencel the closing when the user hits no? I do have a idea on how, becuase I am also a wxPython user and C# seems to none of the less diffrent to me. For the exeption for ";" and brackets in scripts.

      Comment

      Working...