Created
October 21, 2018 14:00
-
-
Save diaolizhi/b0a03305cd7f5c78f7fe2414aa7d3bb5 to your computer and use it in GitHub Desktop.
C# winform 关闭窗口前确认
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Form2_FormClosing(object sender, FormClosingEventArgs e) | |
{ | |
e.Cancel = (MessageBox.Show("Sure?", | |
"Exit", | |
MessageBoxButtons.YesNo, | |
MessageBoxIcon.Question) == DialogResult.Yes); | |
DialogResult result = MessageBox.Show("提示", "确定退出吗?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); | |
if (result == DialogResult.Yes) | |
{ | |
e.Cancel = false; | |
} | |
else | |
{ | |
e.Cancel = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment