private void deleteUnitToolStripMenuItem_Click(object sender, EventArgs e) { if (tabControl1.SelectedTab != null) { string id = tabControl1.SelectedTab.Text; try { mod.DeleteUnit(id); } catch (Exception ex) { MessageBox.Show("Error while deleting " + id + "\r\n" + ex.Message, "Deleting errror", MessageBoxButtons.OK, MessageBoxIcon.Warning); } tabControl1.TabPages.Remove(tabControl1.SelectedTab); } }