110,545
社区成员
发帖
与我相关
我的任务
分享
//点击关闭
private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult re = MessageBox.Show("确定要退出吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (re == DialogResult.Yes)
{
e.Cancel = false;
Application.Exit();
}
else
{
e.Cancel = true;
}
}
private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("确认要关闭软件? ", "关闭 ", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
}
else
{
e.Cancel = true;
}
}
private bool isExit = false; //是否确定退出
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
if (!isExit)
{
DialogResult re = MessageBox.Show("确定要退出吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (re == DialogResult.Yes)
{
e.Cancel = false;
isExit = true;
Application.Exit();
}
else
{
e.Cancel = true;
}
}
} //这样应该可以..