阻止用户关闭程序

来源:互联网 发布:简单的编程代码 编辑:程序博客网 时间:2024/05/22 17:37

private void Form_main_FormClosing(object sender, FormClosingEventArgs e)
{
      if (条件成立)

     {
           e.Cancel = true;
           MessageBox.Show("对不起,您还不能关闭该程序");
           return;
      }
}