/// <summary>
        /// When a resource type is selected the resource list box is populated based on its value.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tabControl_Types_SelectedIndexChanged(object sender, EventArgs e)
        {
            TabPage selectedTab = SelectedTab;

            if (selectedTab != null)
            {
                // Add all controls into the selected tab
                listBox_Resource.Parent   = selectedTab;
                resource_ToolStrip.Parent = selectedTab;
                groupBox_Assoc.Parent     = selectedTab;

                using (EnterpriseTestContext context = new EnterpriseTestContext())
                {
                    listBox_Resource.DataSource = ResourceWindowsCategory.SelectParent(context, selectedTab.Text).ToList();
                }
            }
        }
        private void removeResource_Button_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Deletion is final, are you sure you want to remove?", "Removal confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                using (EnterpriseTestContext context = new EnterpriseTestContext())
                {
                    ResourceWindowsCategory resource = ResourceWindowsCategory.SelectByName(context, listBox_Resource.Text, tabControl_Types.SelectedTab.Text);
                    if (resource.Children.Count > 0)
                    {
                        MessageBox.Show("Please remove all associations before deleting '{0}'.".FormatWith(resource.Name), "Delete Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    context.ResourceWindowsCategories.DeleteObject(resource);
                    context.SaveChanges();

                    listBox_Resource.DataSource = ResourceWindowsCategory.SelectParent(context, SelectedTab.Text).ToList();
                }
            }
        }