Results 1 to 5 of 5

Thread: [2005] Highlighting a listbox item

  1. #1

    Thread Starter
    Hyperactive Member Pac_741's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    298

    [2005] Highlighting a listbox item

    Hi to all,

    i have a listbox that have a lot of items and i would like to give the user the
    ability of searching through those items by just inserting the items name in a textbox and then press a button, and the item that the user inserted on the textbox will be highlight on the listbox, of course if it exist......
    i know how to do this with a textbox but i dont know how to do it with a listbox

    thanks
    C# and WPF developer
    My Website:
    http://singlebits.com/

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Highlighting a listbox item

    Use the FindString or FinsStringExact method of the ListBox to get the index, then set the SelectedIndex property.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member Pac_741's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    298

    Re: [2005] Highlighting a listbox item

    okay........listbox1.findstring(textbox1.text) and then what do i to select the result of that ?
    C# and WPF developer
    My Website:
    http://singlebits.com/

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Highlighting a listbox item

    Read my post again. This time read this bit too:
    set the SelectedIndex property
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member Pac_741's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    298

    Re: [2005] Highlighting a listbox item

    Sorry jmcilhinney, i was trying to make this work with a project i had there must be something wrong, but i wrote the code correctly the first time and i did read your post, i tried it on a new project and it works perfect ! thanks
    C# and WPF developer
    My Website:
    http://singlebits.com/

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