委托一下
this.Closing += new System.ComponentModel.CancelEventHandler(this.FrmMain_Closing);
代码中:
private void FrmMain_Closing(object sender, CancelEventArgs e)
{
DialogResult DR=MessageBox.Show("是否要退出","提示",MessageBoxButtons.YesNo);
if(DR.Equals(DialogResult.Yes))
{
this.OExit();
}
else
{
e.Cancel=true;
}
}