joshface04
New Coder
I have some code which allows us to perform searches/filter data on a list view control. By typing some search criteria into a textbox, the code goes through every listview item and if it matches it keeps it, if not, it gets rid of it. The code itself works great but we also want to be able to use radio buttons to search for products listed in a listview column.
The code checks which radio button is pressed and uses the to determine the product. The code then checks the serial number column in the listview control and if a serial njumber contains two specific letters which are a code for a product, it keeps that listviewitem.
Here's my code:
However; we have several codes for products, so instead of just 'EM' in this example, we need 'EM' 'ML' and 'MX'. I've tried the variable 'product' as an array and put the codes in there but had no joy. What can I do?
The code checks which radio button is pressed and uses the to determine the product. The code then checks the serial number column in the listview control and if a serial njumber contains two specific letters which are a code for a product, it keeps that listviewitem.
Here's my code:
Code:
Dim Product As String
If rbtn_Empower.Checked = True Then
Product = "EM"
End If
Dim pos2 As Int32
Dim listItem2 As ListViewItem
For pos = SUPID_Data.ListView_Search.Items.Count - 1 To 0 Step -1
listItem2 = SUPID_Data.ListView_Search.Items(pos)
If Not listItem2.SubItems(2).Text.IndexOf(Product, 0, StringComparison.CurrentCultureIgnoreCase) > -1 Then
SUPID_Data.ListView_Search.Items.Remove(listItem2)
End If
Next
However; we have several codes for products, so instead of just 'EM' in this example, we need 'EM' 'ML' and 'MX'. I've tried the variable 'product' as an array and put the codes in there but had no joy. What can I do?