public void LoadMidListBox(string filter = null) { Dictionary <string, string> filteredList = new Dictionary <string, string>(); List <ModIdData> values = File.ReadAllLines("modid.csv") .Skip(1) //skip the header .Select(v => ModIdData.FromCsv(v)) .ToList(); foreach (var item in values) { if (filter == "") { lstModValues.DataSource = null; lstModValues.Items.Clear(); return; } // lstModValues.Items.Add(new ListViewItem(new string[] { item.mod, item.mid })); else { if (item.mid.Contains(filter) || item.mod.Contains(filter.ToUpper())) { filteredList.Add(item.mod, item.mid); //lstModValues.Items.Add(new ListViewItem(new string[] { item.mod, item.mid })); Console.WriteLine("conatins"); } } } lstModValues.DataSource = new BindingSource(filteredList, null); }
public static ModIdData FromCsv(string csvLine) { string[] values = csvLine.Split(','); ModIdData ModIdData = new ModIdData(); ModIdData.mod = values[0]; ModIdData.mid = values[1]; return(ModIdData); }