Drop Down Combobox programatically??

gvsbnarayana
gvsbnarayana used Ask the Experts™
on
Hi All,
    is it possible to drop down a Combobox programatically? I am trying to show a combobox on click on a datagrid. I am able to show the combobox on click on the grid but not able to drop it automatically so that the user can directly select.
Thanks in advance.
Regards,
Badri.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Courtesy of Johan Ooghe:

DataCombo1.SetFocus
SendKeys "%{Down}"

(source: http://www.codeguru.com/vb/articles/1743.shtml)

Commented:
Private Declare Function SendMessage _
    Lib "user32" _
    Alias "SendMessageA" ( _
        ByVal hwnd As Long, _
        ByVal wMsg As Long, _
        ByVal wParam As Long, _
        lParam As Long _
        ) As Long

Private Const CB_SHOWDROPDOWN    As Long = &H14F

Public Sub ComboDropdownHide(ByVal cbo As VB.ComboBox)
    SendMessage cbo.hwnd, CB_SHOWDROPDOWN, False, 0
End Sub

Public Sub ComboDropdownShow(ByVal cbo As VB.ComboBox)
    SendMessage cbo.hwnd, CB_SHOWDROPDOWN, True, 0
End Sub

Commented:
This is what I use and it works great.

Private Sub Combo1_GotFocus()
    SendKeys "{F4}"
End Sub
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- answered by Monchanger
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

twalgrave
Cleanup Volunteer
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial