winform关闭窗体事件
private void Form2_FormClosing( object sender, FormClosingEventArgs e) { DialogResult result = MessageBox.Show( "你确定要关闭吗!" , "提示信息" , MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == DialogResult.OK) { e.Cancel = false ; //点击OK } else { e.Cancel = true ; } } |