Start New Discussion within our Software Development Community

Hello need help i have a listview and a textbox
I have this code

ListView_LOB.Focus()
For i = 0 To ListView_LOB.Items.Count - 1
    If ListView_LOB.Items(i).SubItems(1).Text = TextBox1.Text Then
        ListView_LOB.Items(i).Selected = True
    End If
Next

it will highlight the item in Listview it seen in textbox1 for example "Erick"
but if i search again and change the textbox1 example is "Larrie"
it will highlight "Larrie" and also "Erick"

You can either set the ListView MultiSelect property to False, or you can change the code to

ListView_LOP.SelectedIndices.Clear()
ListView_LOB.Focus()

For i = 0 To ListView_LOB.Items.Count - 1
    If ListView_LOB.Items(i).SubItems(1).Text = TextBox1.Text Then
        ListView_LOB.Items(i).Selected = True
    End If
Next
This question has already been answered. Start a new discussion instead.