private void ToolButtonClose_Click(object sender, EventArgs e) { // do stuff based on active tab switch (tabControlMain.SelectedTab.Name) { case "tabPageEntList": EntityListControl.Close(); break; case "tabPageEntDropdown": EntityDropdown.Close(); break; case "tabPageAttrList": AttribListControl.Close(); EntityDropdownAttribList.Close(); break; case "tabPageAttrDropDown": AttributeDropdownBase.Close(); EntityDropdownAttribs.Close(); break; case "tabPageSolution": SolutionDropdown.Close(); break; case "tabPageViewsDropdown": ViewDropdown.Close(); EntityDropdownViews.Close(); break; case "tabPageGlobalOptSets": GlobalOptionSetList.Close(); break; } }