以下代码:提示框会跳出2遍
private void mFrmmain_FormClosing(object sender, FormClosingEventArgs e)
{
if (DialogResult.No == MessageBox.Show("是否关闭", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
{
e.Cancel = true;
}
else
{
Application.Exit();
}
}
修改如下: 即可。
private void mFrmmain_FormClosing(object sender, FormClosingEventArgs e)
{
if (DialogResult.No == MessageBox.Show("是否关闭", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
{
e.Cancel = true;
}
else
{
this.Dispose();
Application.Exit();
}
}