小编Max*_*ard的帖子

如何阻止表单关闭并显示确认对话框?

我希望当用户关闭窗口时,会显示一个MessageBox并询问用户是否确定要关闭窗口.但是当我尝试时,窗口关闭,nevers向我显示MessageBox.

private void SchetsWin_FormClosing(object sender, FormClosingEventArgs e)
{
    if (e.CloseReason == CloseReason.UserClosing)
    {
        e.Cancel = true;
        MessageBox.Show("Example");
    }
}
Run Code Online (Sandbox Code Playgroud)

.net c# winforms

4
推荐指数
1
解决办法
1841
查看次数

标签 统计

.net ×1

c# ×1

winforms ×1