日期:2014-05-16  浏览次数:21026 次

C# FormClosing 为什么要点两次“是”才会退出系统这是为什么?

  private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
           // DialogResult dr =MessageBox.Show("是否退出进销存系统", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (MessageBox.Show("是否退出进销存系统", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)== DialogResult.Yes)        //如果单击“是”按钮
            {
                Application.Exit();              //关闭窗体
            }
            else                                           //如果单击“否”按钮
            {
                e.Cancel = true;                  //不执行操作

            }
        }

------解决方案--------------------
Closing中写的话,你Application.Exit();,又会掉次Main_FormClosing