当前位置:编程学习 > C#/ASP.NET >>

刚学C#:如何取消窗口关闭

private void form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (sSaveFlag == "0")
            {
                DialogResult result;
                result = MessageBox.Show(this ,"有数据没有保存,是否保存数据?","提示",MessageBoxButtons.YesNoCancel,MessageBoxIcon .Question ,MessageBoxDefaultButton .Button1  );

                switch (result )
                {
                    case DialogResult .Yes:
                        this.buttonSav_Click ( sender,  e);
                        break ;
                    case DialogResult .No :
                        break ;
                    case DialogResult .Cancel :
                        //此处代码如何写
                        return;

                }

            }
        } --------------------编程问答-------------------- e.Cancel = true; --------------------编程问答-------------------- try

e.Cancel = true;
--------------------编程问答-------------------- 谢谢了 --------------------编程问答-------------------- 上面都说的;路过 --------------------编程问答-------------------- 来晚了 --------------------编程问答-------------------- 1,2楼的都说了,来晚了 --------------------编程问答-------------------- 额,很受教 --------------------编程问答-------------------- e.Cancel   =   true; 就可以了
--------------------编程问答-------------------- http://baike.baidu.com/view/155969.htm --------------------编程问答-------------------- 学习中! --------------------编程问答-------------------- e.cancel=true. --------------------编程问答--------------------
引用 5 楼 wzq6511 的回复:
来晚了

给力 --------------------编程问答-------------------- e.Cancel   =   false; 
--------------------编程问答-------------------- 在窗体FormClosing事件中编写代码

e.Cancel = true;
--------------------编程问答-------------------- 好好学习一下
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,