C#窗体卸载事件
窗体卸载事件:
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult.OK == MessageBox.Show("你确定要关闭应用程序吗?", "关闭提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { this.FormClosing -= new FormClosingEventHandler(this.Form1_FormClosing);//为保证Application.Exit();时不再弹出提示,所以将FormClosing事件取消 // bq = new bq80xRW(); // bq.CloseDevice(); Application.Exit();//退出整个应用程序 } else { e.Cancel = true; //取消关闭事件 } }