Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Multiple times closing window occurring

What I have tried:

private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
    DialogResult d = MessageBox.Show("Do u want to close application", "Exit", MessageBoxButtons.YesNo);
    if (d == DialogResult.Yes)
    {
        Application.Exit();
    }
    else if(d==DialogResult.No)
    {
        e.Cancel = true;
    }
}
Posted
Updated 22-Sep-18 22:46pm

1 solution

Debugging will explain why... Set a breakpoint in the Form2_FormClosing event, look at the stack trace each time you hit the breakpoint and you will see why.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900