Click here to Skip to main content
14,733,599 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! Would like to know where to find a search funcion for how to search to an listview that are saved in an text file.
Posted

1 solution

If you want to do this based on the listview items, one way is to loop through the listviewitems and their subitems. For example the following selects all the items where desired text is found in the item or in the subitem.
foreach(ListViewItem item in mylistview.Items) {
   if (item.Text.Contains("text to search")) {
      item.Selected = true;
   }
   foreach (ListViewItem.ListViewSubItem subitem in item.SubItems) {
      if (item.Text.Contains("text to search")) {
         item.Selected = true;
      }
   }
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900