CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    1

    Listview auto highlight






    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

  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Listview auto highlight



    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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured