I have a multi-column ListView that contains Computer Name, Date of Purchase and Operating System.

I use a Linq Query to display results matching "HP" laptops which erases existing ListView items and adds rows matching my query.

string findWhat = HP";

var list = listView1.Items
   .Cast<ListViewItem>()
   .Where(
   x => x.SubItems
   .Cast<ListViewItem.ListViewSubItem>()
   .Any(y => y.Text.Contains(findWhat)))
   .ToArray();

listView1.Items.Clear();
listView1.Items.AddRange(list);

I want to be able to dynamically check-up rows whenever I search for "HP" laptops.

0 Answers