Article ID: 161161 - Last Review: February 24, 2005 - Revision: 2.2 HOWTO: Search a ListBox Control QuicklyThis article was previously published under Q161161 On This PageSUMMARY
A popular item in a user interface is to "link" a text box to a list box so
the nearest match in the list box is selected when the user types text into
the text box. This technique can be implemented using pure Visual Basic
code, but the Windows API provides a quicker and easier way to do this.
MORE INFORMATION
The technique calls the Windows API SendMessage function using the
LB_FINDSTRING message for a list box to locate a partial match for a string
in the list box. SendMessage requires the following parameters:
SendMessage(hWnd, LB_FINDSTRING, wParam, lParam) where
hWnd - is the hWnd of the list box.
wParam - is a long that specifies the starting point for the
search. Use -1 to search the whole list box.
lParam - is a long pointer to the string to find.
Step-by-Step Example
REFERENCES
See the Help topic "Control Limitations" in the Visual Basic documentation.
APPLIES TO
| Article Translations
|
Back to the top
