private void ClearFields() { if (SelectedDatabase.SelectedItem.ToString() == "Games") { foreach (Control c in MainTableLayout.Controls) { if (c.GetType() == GameNameTextbox.GetType() || c.GetType() == DescriptionTextBox.GetType()) c.Text = ""; } DateTextbox.Value = DateTime.Today; DataChanged = false; PosterBox.BackgroundImage = null; IconBox.BackgroundImage = null; SelectedGame = null; for(int i = 0; i < ListboxPlatforms.Items.Count; i++) { ListboxPlatforms.SetSelected(i, false); } } if (SelectedDatabase.SelectedItem.ToString() == "Platforms") { foreach (Control c in PlatformTableLayout.Controls) { if (c.GetType() == PlatformNameTextbox.GetType()) c.Text = ""; } PlatformIconBox.BackgroundImage = null; SelectedPlatform = null; } }