我将退出按钮作为菜单项,并显示确认消息 以下代码完成工作,但是当我试图处理X按钮时,我收到确认消息两次我试图在菜单项的退出按钮上注释消息,但是当我点击时仍然收到消息两次是的
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; }
}
答案 0 :(得分:3)