private void TabControlChars_Leave(object sender, EventArgs e) { DataTable charChanges = null; if (charsTypeDT != null) { charChanges = charsTypeDT.GetChanges(); } else if (charsDT != null) { charChanges = charsDT.GetChanges(); } if (charChanges != null) { DialogResult result; result = MessageBox.Show("Changes were made without saving !!\n" + "All Changes will be lost ...", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { ??? } } }