winform窗口关闭提示

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("你确定要退出本系统吗?", "退出", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
{
Application.ExitThread();
}
else { e.Cancel = true;
}
}

你可能感兴趣的:(WinForm)