关闭时代码

if(MessageBox.Show("确定关闭系统吗?","关闭确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) == DialogResult.OK){
                Application.Exit();
            }

如果有多个地方要写,可以把上面写成

/// <summary>
        /// 关闭系统
        /// </summary>
        public void ExitApp(){
            if(MessageBox.Show("确定关闭系统吗?","关闭确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) == DialogResult.OK){
                Application.Exit();
            }
        }

在其它地方只要调用this.ExitApp();就可以了。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2021-10-09
  • 2022-01-07
  • 2021-12-30
猜你喜欢
  • 2021-09-27
  • 2021-08-12
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
相关资源
相似解决方案