how can I, using Code, force a combo box control to drop down the list? in VBA it's simple:
combo1.dropdown
How can I do the same in VB?
Printable View
how can I, using Code, force a combo box control to drop down the list? in VBA it's simple:
combo1.dropdown
How can I do the same in VB?
Use the CB_SHOWDROPDOWN API Message with the SendMessage Function, ie.
------------------Code: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 CB_SHOWDROPDOWN = &H14F
Private Sub Command1_Click()
SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, True, ByVal 0&
End Sub
Private Sub Form_Load()
Dim iIndex As Integer
For iIndex = 1 To 10
Combo1.AddItem "Item " & iIndex
Next
End Sub
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Is that the only way to do it? It just seems like it's pretty drawn out for such a simple thing. Having to make an API call to do something so simple. Thanks though
You could use the SendKeys Function, if you wanted to:
Code:Private Sub Command1_Click()
Combo1.SetFocus
SendKeys "%{DOWN}", 1
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]