我希望当用户关闭窗口时,会出现一个消息框询问用户是否确定要关闭窗口。但是当我尝试时,窗口只是关闭了,从未显示消息框。
private void SchetsWin_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
MessageBox.Show("Example");
}
}
SchetsWin.FormClosing += SchetsWin_FormClosing;
。 - DonBoitnott