Why does Application.Exit Prompt me twice?

Posted by Michael Quiles on Stack Overflow See other posts from Stack Overflow or by Michael Quiles
Published on 2010-06-01T15:49:27Z Indexed on 2010/06/01 15:53 UTC
Read the original article Hit count: 173

Filed under:

How can I stop the message box from showing up twice when I press the X on the form ? FYI the butoon click works fine it's the X that prompts me twice.

   private void xGameForm_FormClosing(object sender, FormClosingEventArgs e)
   {
       //Yes or no message box to exit the application
       DialogResult Response;
       Response = MessageBox.Show("Are you sure you want to Exit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
       if (Response == DialogResult.Yes)
           Application.Exit();

   }
   public void button1_Click(object sender, EventArgs e)
   {
       Application.Exit();
   }

© Stack Overflow or respective owner

Related posts about c#