Click to See Complete Forum and Search --> : Listview auto highlight


Philip Tsang
March 19th, 1999, 11:13 AM
I have one question about Listview control. For example : User press

"Item One" in text box , after pressing enter . The software will search

"Item One" in Listview , if it find it , it will auto highlight this item .

if no this data , will appear message .

How do i make auto hightlight ?

Thank you for your help



Philip

Chris Eastwood
March 19th, 1999, 11:27 AM
Hi


This is quite simple, the ListView has a FindItem method which will search for a matching string in the listview (and in columns if you specify it - look at the help file for more info).


EG.


Dim li As ListItem



Set li = ListView1.FindItem("This is xline 75")

If li Is Nothing Then

MsgBox "Not Found"

Exit Sub

End If



li.EnsureVisible

Set ListView1.SelectedItem = li


Don't forget to set the 'HideSelection' property of the listview to false.


Regards


Chris Eastwood

CodeGuru - the website for developers

http://www.codeguru.com/vb