private void Setup() { List<string> temp_list = new List<string>(specieslist); temp_list.Sort(); CB_Species.DataSource = temp_list.Select(mon => new Util.cbItem { Text = mon, Value = Array.IndexOf(specieslist, mon) }).ToList(); List<string> items = new List<string>(itemlist); List<string> sorted_items = new List<string>(itemlist); List<Util.cbItem>[] item_lists = new List<Util.cbItem>[item_spec.Length]; for (int i = 0; i < item_lists.Length; i++) item_lists[i] = new List<Util.cbItem>(); sorted_items.Sort(); for (int i = 0; i < items.Count; i++) { int index = items.IndexOf(sorted_items[i]); { Util.cbItem ncbi = new Util.cbItem(); if (sorted_items[i] == "???") continue; // Don't allow stubbed items. ncbi.Text = sorted_items[i] + " - " + index.ToString("000"); ncbi.Value = index; foreach (List<Util.cbItem> l in item_lists) l.Add(ncbi); } items[index] = ""; } for (int i = 0; i < item_spec.Length; i++) { item_spec[i].ValueMember = "Value"; item_spec[i].DisplayMember = "Text"; item_spec[i].DataSource = item_lists[i]; item_spec[i].SelectedValue = 0; } loaded = true; }
private void populateComboBoxes() { // Set the Text CB_HeldItem.DisplayMember = CB_Species.DisplayMember = CB_Ability.DisplayMember = CB_Nature.DisplayMember = CB_GameOrigin.DisplayMember = CB_HPType.DisplayMember = "Text"; // Set the Value CB_HeldItem.ValueMember = CB_Species.ValueMember = CB_Ability.ValueMember = CB_Nature.ValueMember = CB_GameOrigin.ValueMember = CB_HPType.ValueMember = "Value"; var Any = new Util.cbItem {Text = "Any", Value = -1}; var DS_Species = new List<Util.cbItem>(Main.SpeciesDataSource); DS_Species.RemoveAt(0); DS_Species.Insert(0, Any); CB_Species.DataSource = DS_Species; var DS_Item = new List<Util.cbItem>(Main.ItemDataSource); DS_Item.Insert(0, Any); CB_HeldItem.DataSource = DS_Item; var DS_Nature = new List<Util.cbItem>(Main.NatureDataSource); DS_Nature.Insert(0, Any); CB_Nature.DataSource = DS_Nature; var DS_Ability = new List<Util.cbItem>(Main.AbilityDataSource); DS_Ability.Insert(0, Any); CB_Ability.DataSource = DS_Ability; var DS_Version = new List<Util.cbItem>(Main.VersionDataSource); DS_Version.Insert(0, Any); CB_GameOrigin.DataSource = DS_Version; string[] hptypes = new string[Main.types.Length - 2]; Array.Copy(Main.types, 1, hptypes, 0, hptypes.Length); var DS_Type = Util.getCBList(hptypes, null); DS_Type.Insert(0, Any); CB_HPType.DataSource = DS_Type; // Set the Move ComboBoxes too.. var DS_Move = new List<Util.cbItem>(Main.MoveDataSource); DS_Move.RemoveAt(0); DS_Move.Insert(0, Any); { foreach (ComboBox cb in new[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4 }) { cb.DisplayMember = "Text"; cb.ValueMember = "Value"; cb.DataSource = new BindingSource(DS_Move, null); } } // Trigger a Reset resetFilters(null, null); }