Summary:
Procedure allows you to programatically show or hide a combobox's dropdown list.
Arguments:
WhichCombo - a reference to the combobox
DropItDown - Boolean: True to Show list, False to Hide list
VB Code:
'declare api procedures
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
'declare constants
Public Const CB_SHOWDROPDOWN = &H14F
Public Sub DropList(WhichCombo As Control, DropItDown As Boolean)
On Error Resume Next
Dim vTmpLng as Long
vTmpLng = SendMessage(WhichCombo.hWnd, CB_SHOWDROPDOWN, _
ByVal Abs(CLng(DropItDown)), ByVal CLng(0))
End Sub
Usage Example:
VB Code:
DropList Form1.Combo1, True
Notes:
As written, this code is intended to be placed in a module, and then called as needed. In order to place this code in a form, you will have to change the API and Constant declarations to 'Private'