private void This_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //Before closing, we try to save the current state: RegularSaver.Save(this.tdTreeDesigner); DialogClosingApplication closingDialog = new DialogClosingApplication(); if (closingDialog.ShowDialog() == true) { if (closingDialog.YesClicked) { e.Cancel = false; } else { e.Cancel = true; } } }