Hi,
How is the information your searching stored? for examle is it stored in a database.
Cheers
John
discovery-power
Junior Poster in Training
94 posts since Oct 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
See if this helps.
1 ListView, 1 TextBox(for search value), 1 Button(to search)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Not ListView1.MultiSelect = False Then ListView1.MultiSelect = False '// disable MultiSelection of items.
If TextBox1.Text = "" Then Exit Sub '// do not search on empty search value.
For Each itm As ListViewItem In ListView1.Items '// loop thru all items.
If itm.Text = TextBox1.Text Then '// check if itm.Text equals search value.
itm.Selected = True '// select item.
itm.EnsureVisible() '// if itm is not visible in ListView, make sure it is.
ListView1.Select() '// select the ListView to show highlighted item.
Exit For '// exit loop since itm found.
End If
Next
End Sub
Or you can change the item's.BackColor if found.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then Exit Sub '// do not search on empty search value.
For Each itm As ListViewItem In ListView1.Items '// loop thru all items.
If itm.Text = TextBox1.Text Then '// check if itm.Text equals search value.
itm.BackColor = Color.GreenYellow '// change item.BackColor if found.
itm.EnsureVisible() '// if itm is not visible in ListView, make sure it is.
Else
itm.BackColor = ListView1.BackColor '// change all other items BackColor to ListView.BackColor.
End If
Next
End Sub
codeorder
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8
Seems like this new issue is not caused by the code I have provided, but by code in your Public Function findlrecords() As Integer .
You can add a Try/Catch statement in your Function for the time being and start a new thread for this new issue caused by your Function.
Glad I could help otherwise.
codeorder
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8
Question Answered as of 2 Years Ago by
codeorder
and
discovery-power