简体   繁体   中英

FormClosing shows Exit Confirm MessageBox two times

I am facing a problem on form closing. It's shows my exit confirm message box 2 times and and ask 2 times "Are you sure to exit?":

if (MessageBox.Show("Are you sure to exit. Confirm?", "Rest O Rant", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
    Application.Exit();
    MessageBox.Show("Thank You For Using Rest O Rant Software.", "Closing message!", MessageBoxButtons.OK);
}
else
{
    e.Cancel = true;
    this.Activate();
}   

try this code

MessageBox.Show("Thank You For Using Rest O Rant Software.", "Closing message!", MessageBoxButtons.OK);

Application.Exit();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM