We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,453 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Listview Search Using a Textbox

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"

3
Contributors
1
Reply
1 Hour
Discussion Span
4 Months Ago
Last Updated
8
Views
Question
Answered
Zick Technology
Junior Poster
183 posts since Dec 2012
Reputation Points: 0
Solved Threads: 2
Skill Endorsements: 3

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
Reverend Jim
Illigitimae non carborundum
Moderator
3,740 posts since Aug 2010
Reputation Points: 585
Solved Threads: 469
Skill Endorsements: 33
Question Answered as of 3 Months Ago by Reverend Jim

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.3175 seconds using 2.65MB