前沿拓展:
dialogresult
樓上的說的挺仔細了,這是一個例子,運行下就知道了.
string message = “You did not enter a server name. Cancel this operation?”;
string caption = “No Server Name Specified”;
MessageBoxButtons buttons = MessageBoxButt石編至型刻幾步酸ons.YesNo;
DialogResult
拓展知識:
dialogresult
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
MessageBox.Show("提示?", "是否確認退出?",MessageBoxButtons.OKCancel,MessageBoxicon.information)
}
其實不用判斷.點擊窗口右上角的X,會彈出對話框,如果選擇是OK的話,會關(guān)閉窗口,點取消相當與什么都沒做
dialogresult
this.Dispose(); //釋放資源
this.Close(); //關(guān)閉程序(窗口)
dialogresult
取消按鈕是自己設(shè)計的話,直接把form 的cancel result button設(shè)置成這個button;
或者在點擊button的時候this.dialogresult=cancel;
dialogresult
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("確定關(guān)閉窗口?", "", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
{
e.Cancel = true;
}
}
原創(chuàng)文章,作者:九賢生活小編,如若轉(zhuǎn)載,請注明出處:http:///33436.html