How do you make the combo box select the nearest match when you type in the search field (automatically select it) when you resize it so that it's all visible?
Printable View
How do you make the combo box select the nearest match when you type in the search field (automatically select it) when you resize it so that it's all visible?
dont get it ... could you elaborate a bit please ?
Can you please explain a bit more .
OK, get a combo box, and populate it with a few number for example 0011,0013,0016 ok, now drag the bottom border down so that it reveals the list under it (looks like a textbox and a listbox put together) and start typing 0016. As you will see, it doesn't highlight the closest match to what you have in the text field. Is there a way to make it select the first object and keep selecting the closest match until it gets the correct one? the best it can do is scroll the box but that's useless if the item is towards the bottom.
use api function sendmessage .
declare section....
Private Const CB_FINDSTRING As Long = &H14C
Private Const CB_FINDSTRINGEXACT As Long = &H158
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
in the keypress event of combobox :
indx = SendMessage(combo1.hwnd, CB_FINDSTRING, -1, _
ByVal SearchKey)
indx will give u the listindex of the nearest search . :)