关闭窗体时,弹出对话框,我单击取消,如何不退出窗体,而返回原状态。

解决方案 »

  1.   

    写在 Form_QueryUnload 事件里面。
    if (MessageBox.Show("xxxx") == DialogBoxResoult.Cancel) e.Cancel = true;
      

  2.   

    private void mainForm_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (MessageBox.Show("确定要退出程序吗?", "退出确认", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    e.Cancel = true;
                }
            }
      

  3.   

    正解!e.Cancel = true;
      

  4.   

    vs2008中没有 Form_QueryUnload 好像
      

  5.   

    vs2008中没有 Form_QueryUnload 好像
      

  6.   

    如果不是点红叉关闭窗体,而是点窗体中的某个按钮如cancel关闭,又该如何写呢?