它(MessageBox)檢查檔案是否保存
單擊是時我想關閉表單
并在單擊否時回傳應用程式
我在檔案和問題中搜索了很多但沒有找到答案
我的意思是,有“MessageBox.Show()”,不是有“MessageBox.Close()”嗎?
這就是我所擁有的:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
var message = "The File Is Not Saved\nDo You Want To Close?";
var title = "File Not Saved";
var buttons = MessageBoxButtons.YesNo;
if (FSaved == false)
{
var res = MessageBox.Show(message, title, buttons);
if (res == DialogResult.Yes)
{
this.Close();
}
else if (res == DialogResult.No)
{
return;
}
}
}
uj5u.com熱心網友回復:
你讓你用事件 args - 取消關閉e。
e.Cancel = true;
你也不應該打電話Close()來,FormClosing因為它已經在出去了。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/510001.html
標籤:C#表格
下一篇:按列寬自動拉伸ListView行
