我试图在关闭菜单表单时关闭我的应用程序。这是我的代码:
private void frmMenu_FormClosing(object sender, FormClosingEventArgs e)
{
var result = MessageBox.Show("Do you want to close this application",
"Alert", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
//this.Close();
Application.Exit();
//e.Cancel = false;
}
else
{
e.Cancel = true;
}
}
关闭时此消息出现两次。