Hi all,

I am using the following code for my searching function, but when I try to run it, it are allow me to search the item for column 1, but I want to search the item for column 2 as well columun 3, what mistake I have make, can anyone give me some advice on this?

This is my code:,
Private Sub ListView_Master_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView_Master.ColumnClick

Dim exactMatch As Boolean
Dim mySearchText As String

Select Case e.Column
Case 0 'column one BOM ID
'Search for item at column 0 when user click on column 0
'MsgBox(e.Column)

Case 1 'column two Cust Part # = BOM
'Search for item at column 1 when user click on column 1

MsgBox(e.Column)

mySearchText = Trim(InputBox("Please enter your Customer Part #", "Search Product Master Entry Data"))

For Each itm As ListViewItem In ListView_Master.Items
If exactMatch Then
If itm.Text = mySearchText Then
' an exact match was found ...
MsgBox("Exact")
End If
Else
mySearchText &= "*"
If itm.Text Like mySearchText Then
' a partial match was found ...
MsgBox("Partial")
End If
End If
Next

Case 2 'column three Child Part#A = CodeAChild Part#B = CodeB
'Search for item at column 2 when user click on column 2
MsgBox(e.Column)

Case 3 'column three Child Part#B = CodeB
'Search for item at column 3 when user click on column 3

MsgBox(e.Column)

End Select

End Sub

Dim Var1 as string = Me.ListView1.SelectedItems(0).SubItems(0).Text

...

Dim Var5 as string =Me.ListView1.SelectedItems(0).SubItems(4).Text

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.