Arslan Ali

Arslan Ali

  • NA
  • 69
  • 11.5k

Multi Column Search In ListView ( C# ,Visual Studio 2015 )

Aug 20 2018 12:56 AM
HI , I am using this code on OnKeyPress event , which filters my list View, but it only searches in the 1st Column of the List View .. Need Help ..
  1. for (int i = lv_panel_products.Items.Count - 1; i >= 0; i--)  
  2. {  
  3.     ListViewItem lvi = lv_panel_products.Items[i];  
  4.     foreach (ListViewItem.ListViewSubItem subitem in lv_panel_products.Items)  
  5.     {  
  6.         if (lvi.Text.ToLower().Contains(txt_searchproducts.Text.ToLower()) || subitem.Text.ToLower().Contains(txt_searchproducts.Text.ToLower()))  
  7.         {  
  8.             lvi.BackColor = Color.Black;  
  9.         }  
  10.         else  
  11.         {  
  12.             lv_panel_products.Items.Remove(lvi);  
  13.         }  
  14.     }  
  15. }  

Answers (8)