winform 右侧关闭按钮事件

       private void AlarmDemo_FormClosing(object sender, FormClosingEventArgs e)
        {
         
            ////MessageBox.Show("你按下了ESC");
            DialogResult dr = MessageBox.Show("确定要退出吗?", "退出系统", MessageBoxButtons.OKCancel);
            if (dr == DialogResult.OK)//如果点击“确定”按钮
            {
                FormPassword form = new FormPassword();
                form.StartPosition = FormStartPosition.CenterScreen;
                form.ShowDialog();

            }
            e.Cancel = true;
        }

 

posted @ 2020-03-17 09:09  enych  阅读(809)  评论(0编辑  收藏  举报