0

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"

Edited by Reverend Jim: Fixed formatting

2
Contributors
1
Reply
9
Views
4 Years
Discussion Span
Last Post by Reverend Jim
0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.