Hallo GraFri
16.09.2003 20:24:04
Friedrich
Add the following code to a BAS module:
--------------------------------------------------------------------------------
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2003 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
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
Public Const CB_SHOWDROPDOWN = &H14F
'--end block--'
Form Code
On a form, add a two command buttons and a combo box. Add the following code to the form:
--------------------------------------------------------------------------------
Option Explicit
Sub Form_Load()
Combo1.AddItem "Item 1"
Combo1.AddItem "Item 2"
Combo1.AddItem "Item 3"
Command1.Caption = "Show List"
Command2.Caption = "Hide List"
End Sub
Private Sub Command1_Click()
'Drop the list
Call SendMessage(Combo1.hWnd, CB_SHOWDROPDOWN, True, ByVal 0)
End Sub
Private Sub Command2_Click()
'Close List
Call SendMessage(Combo1.hWnd, CB_SHOWDROPDOWN, False, ByVal 0)
End Sub
'--end block--'
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.