I made an exit button as menu item with confirmation message and below code do the job,.. but when I am trying to handle the X button I am getting the confirmation message twice I tried to comment the message on the exit button on the menu item but still getting the message twice when I click on YES
private void ExitMenuItem_Click(object sender, EventArgs e)
{
/*DialogResult result;
result = MessageBox.Show("are you sure?", "exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
Application.Exit();
}
else
{ return; }*/
}
private void F0101_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult result;
result = MessageBox.Show(""are you sure?", "exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
Application.Exit();
}
else
{ e.Cancel = true; }
}