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; }