- Home
·
- Miscellaneous
·
- Do you want to Search in ComboBox or ListBox as soon as you type in TextBox, ONLY 1 API Call and 2
Do you want to Search in ComboBox or ListBox as soon as you type in TextBox, ONLY 1 API Call and 2
Do you want to Search in ComboBox or ListBox as soon as you type in TextBox, ONLY 1 API Call and 2 Lines of code,very easy and very
Rate Do you want to Search in ComboBox or ListBox as soon as you type in TextBox, ONLY 1 API Call and 2
(1(1 Vote))
'add a textbox(text1),a listbox(list1) and a combobox(combo1)then add then following:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Const LB_FINDSTRING = &H18F
Const CB_FINDSTRING = &H14C
Private Sub Form_Load()
'Add some items to the listbox
With List1
.AddItem "Computer"
.AddItem "Screen"
.AddItem "Modem"
.AddItem "Printer"
.AddItem "Scanner"
.AddItem "Sound Blaster"
.AddItem "Keyboard"
.AddItem "CD-Rom"
.AddItem "Mouse"
End With
With Combo1
.AddItem "Computer"
.AddItem "Screen"
.AddItem "Modem"
.AddItem "Printer"
.AddItem "Scanner"
.AddItem "Sound Blaster"
.AddItem "Keyboard"
.AddItem "CD-Rom"
.AddItem "Mouse"
End With
Text1.Text = ""
End Sub
Private Sub Text1_Change()
'Retrieve the item's listindex
List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1, ByVal CStr(Text1.Text))
Combo1.ListIndex = SendMessage(Combo1.hwnd, CB_FINDSTRING, -1, ByVal CStr(Text1.Text))
End Sub
Do you want to Search in ComboBox or ListBox as soon as you type in TextBox, ONLY 1 API Call and 2 Comments
No comments yet — be the first to post one!
Post a Comment