'Declarations
'Add the following code to the declarations section of a 'basic module. Public Declare Function SendMessageLong Lib "user32" _ Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam _ As Long, ByVal lParam As Long) As Long Public Const CB_SHOWDROPDOWN = &H14F 'Form Code 'Add 2 command buttons and a combo box to a form. 'Add the following code to the form. Sub Form_Load() Combo1.AddItem "Item 1" Combo1.AddItem "Item 2" Combo1.AddItem "Item 3" End Sub Private Sub Command1_Click() 'label this button Show List Dim r as Long r = SendMessageLong(Combo1.hWnd, CB_SHOWDROPDOWN, True, 0) End Sub Private Sub Command2_Click() 'label this button Hide List Dim r as Long r = SendMessageLong(Combo1.hWnd, CB_SHOWDROPDOWN, False, 0) End Sub This code shows how to programmatically drop and retract a combo box list portion. Comments Run the project, and click command1 to show the combo box list, or command2 to hide it. This routine only applies to combo boxes whose style is 0 - Dropdown Combo, or 2 - Dropdown List. |