PDA

Click to See Complete Forum and Search --> : Linking a text box to a list box


Gimpster
Nov 5th, 1999, 01:15 AM
I would like to create a list box similar to those in help files where you have a list of all available topics, and then you have a text box at the top, and as you type it highlights any matching entries. How would you do this? Please give code, if you can. Thank you.

------------------
Ryan
corneslen@hotmail.com
ICQ# 47799046


[This message has been edited by Gimpster (edited 11-05-1999).]

Yonatan
Nov 5th, 1999, 02:35 AM
There's a function which does this which is built into the ListBox. Unfortunately, it isn't built into the Visual Basic ListBox. But you can still use it, indirectly:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const LB_FINDSTRING = &H18F

Private Sub Text1_Change()
List1.ListIndex = SendMessage(List1.hWnd, LB_FINDSTRING, -1, ByVal Text1.Text)
End Sub

------------------
Yonatan
Teenage Programmer
E-Mail: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/19552879)

[This message has been edited by Yonatan (edited 11-05-1999).]

Gimpster
Nov 5th, 1999, 03:50 AM
Thanks, it works great!

------------------
Ryan
corneslen@hotmail.com
ICQ# 47799046