Winform 窗体关闭事件

//窗体关闭前事件
        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult result = MessageBox.Show("确认退出吗?", "退出询问",
                MessageBoxButtons.OKCancel,
                MessageBoxIcon.Question);
            if(result == DialogResult.Cancel)
            {
                e.Cancel = true;
            }else
            {
                e.Cancel = false;
            }
        }
 //窗体关闭前事件privatevoidFrmMain_FormClosing(object sender, FormClosingEventArgs e) { DialogResult result = MessageBox.Show("确认退出吗?", "退出询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if(result == DialogResult.Cancel) { e.Cancel = true; }else { e.Cancel = false; } }

相关内容推荐