?
Solved

Find & Select list item in list

Posted on 2005-05-05
6
Medium Priority
?
358 Views
Last Modified: 2008-01-09
I have a vb.net app with a listbox with some stock numbes in it and a textbox and a 'Find' button.
How would I enter a stock number into the textbox, click find, and have it highlight that stock number in the list so I don't have to search by eye?
0
Comment
Question by:Matrix1000
  • 3
  • 2
6 Comments
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 100 total points
ID: 13939435
Is the ListBox bound with DisplayMember and ValueMember?

Do you want to search by value or by text?

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13939444
Assuming WinForms application, not ASP.NET.
0
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 1900 total points
ID: 13939797
   Private Sub cbFind_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles cbFind.Click

        Dim index As Integer = -1

        index = lbStock.FindStringExact(tbFind.Text)
        If index <> -1 Then
            lbStock.SelectedIndex = index
        End If

    End Sub
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:Matrix1000
ID: 13940259
I'd like to search by text...
Thanks
0
 
LVL 1

Author Comment

by:Matrix1000
ID: 13940302
FernandoSoto your example worked great thanks!

What can I do to modify the code to show a message if the stocknumber was not found?
0
 
LVL 1

Author Comment

by:Matrix1000
ID: 13940314
figured it out thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question