我添加了如下代码
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            DialogResult r = MessageBox.Show("是否关闭窗口!", "关闭窗口!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (r==DialogResult.No )
            {
                e.Cancel = true;
            }
        }
怎么我关闭时没有提示,刚学C#,向大家请教下

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    ========
    引用
      

  2.   

    Form1_Closing
    你注册了这个事件没有?
    this.Closing += new...
      

  3.   

    ms有个onclose事件哈,在那事件里加你的代码看看
      

  4.   

    运行调试下.如果通过.说明OnClose事件已经注册..
    你在找找其他原因..