Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight item in a listbox based on entry in the textbox

Status
Not open for further replies.

5bhaya

Technical User
Jul 30, 2002
11
0
0
CA
I have a listbox that has two columns: EmployeeID and FullName (which is an employee full name). I have a textbox and what I would like to accomplish is that when a user types a letter in the textbox, the item in the list box (EmployeeID is a boundcolumn for the listbox )should be highlighted based on this input in the textbox. I have a code in the keypress_event of the textbox which passses on the letter typed to the procedure. The idea is to compare this string to each name in the listbox in a loop and if both strings are equal, to highlight the item in a listbox. The problem is I cannot find a property in the listbox that could give me the employee name (e.g. combo box has a list property)in iteration. Any idea/help shall be appreciated. What I would like to accomplish is if 's' is typed in the textbox, the listbox selection shall highlight a name begining with S.
 
Hi!

In the textbox's change event you can use the following code:

Dim intRow As Integer

For intRow = 0 To Me!YourListBox.ListCount - 1
If Me!YourListBox.Columns(1, intRow) Like Me!YourTextBox.Text & "*" Then
Me!YourListBox.Selected(intRow) = True
Exit For
End If
Next intRow

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top