public Form1() { InitializeComponent(); // Adds the Form1_FormClosing function to FormClosing, otherwise function will not execute this.FormClosing += Form1_FormClosing; // Creates new inventory with file path inventory = new Inventory(filePath); // Tries to load the inventory // if it fails, a message box is displayed and form is closed try { inventory.LoadInventory(); } catch { MessageBox.Show("ERROR: Inventory file not found."); System.Windows.Forms.Application.Exit(); } // Adds each item in the inventory to the list box for (int i = 0; i < inventory.items.Count; ++i) { itemListBox.Items.Add(inventory.items[i].Display()); } // Sets filter to inactive filterActive = false; // Creates new dictionary for filteredIndex filteredIndex = new Dictionary<int, int>(); // Adds the 3 possible types to each combo box, sets the drop down style to drop down list, and sets default type to Movie searchTypeComboBox.Items.AddRange(new string[] { "Movie", "Game", "Book" }); searchTypeComboBox.DropDownStyle = ComboBoxStyle.DropDownList; searchTypeComboBox.SelectedItem = "Movie"; filterTypeComboBox.Items.AddRange(new string[] { "Movie", "Game", "Book" }); filterTypeComboBox.DropDownStyle = ComboBoxStyle.DropDownList; filterTypeComboBox.SelectedItem = "Movie"; addTypeComboBox.Items.AddRange(new string[] { "Movie", "Game", "Book" }); addTypeComboBox.DropDownStyle = ComboBoxStyle.DropDownList; addTypeComboBox.SelectedItem = "Movie"; infoTypeComboBox.Items.AddRange(new string[] { "Movie", "Game", "Book" }); infoTypeComboBox.DropDownStyle = ComboBoxStyle.DropDownList; infoTypeComboBox.SelectedItem = "Movie"; // Sets selected index to 0 (with way program is designed, an item must be selected to function as intended) itemListBox.SelectedIndex = 0; // Adds the possible platforms and genres to each corresponding combo box searchPlatformComboBox.Items.AddRange(inventory.platformsDict[(string)searchTypeComboBox.SelectedItem].ToArray()); infoPlatformComboBox.Items.AddRange(inventory.platformsDict[(string)infoTypeComboBox.SelectedItem].ToArray()); addPlatformComboBox.Items.AddRange(inventory.platformsDict[(string)addTypeComboBox.SelectedItem].ToArray()); filterPlatformComboBox.Items.AddRange(inventory.platformsDict[(string)filterTypeComboBox.SelectedItem].ToArray()); infoGenreComboBox.Items.AddRange(inventory.genresDict[(string)infoTypeComboBox.SelectedItem].ToArray()); addGenreComboBox.Items.AddRange(inventory.genresDict[(string)infoTypeComboBox.SelectedItem].ToArray()); // Sets drop down style to drop down list searchPlatformComboBox.DropDownStyle = ComboBoxStyle.DropDownList; filterPlatformComboBox.DropDownStyle = ComboBoxStyle.DropDownList; }