Results 1 to 7 of 7

Thread: drop down a drop down list?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Is it possible to hit a command button and have a drop down list drop down so the user can see all the choices without clicking on it first?

    Thanks,

    Dan

  2. #2
    Addicted Member
    Join Date
    Aug 1999
    Location
    Hamilton, New Zealand
    Posts
    137
    You could try having a hidden listbox under the button and use the following code.

    Code:
      Private Sub command1_Click()
        list1.visible = True
      End Sub
    Regards

    Matt Brown
    Hamilton, NZ
    VB6 C++ in Visual Studio 6sp4
    VB.net Beta 1

  3. #3
    Guest
    Or you can send a message to the combo box eg:

    SendMessage Combo1.hWnd, CB_SHOWDROPDOWN, 0, 0

    which does the same thing

    - gaffa

  4. #4
    Guest
    Here are the functions you need in order for the code above to work.

    Code:
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long 
    
    Const CB_SHOWDROPDOWN = &H14F

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Thanks for the help Mathew and gaffa, but it doesn't do a thing.. I put Mathew's code in the module and put gaffa's code verbatum (except for putting in the proper combo box name) behind the command button but it doesn't do a thing..

    Any ideas?

    Thanks,

    Dan

  6. #6
    Guest
    I was at skool when I posted, so I couldn't test it.

    Try this:

    Code:
    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 = &H14F
    
    Private Sub Command1_Click()
    
    Dim lRet as long
    lRet = SendMessage(Combo1.hwnd, CB_SHOWDROPDOWN, 1, ByVal 0&)
    
    End Sub
    By the way, Mathew = Matthew = two t's.

  7. #7
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'drop down a combobox when it gains focus
    Dim bAlreadyDown As Boolean
    
    Private Sub Combo1_DropDown()
      bAlreadyDown = True
    End Sub
    
    Private Sub Combo1_GotFocus()
      If bAlreadyDown = False Then SendKeys ("{f4}")
      bAlreadyDown = False
    End Sub
    
    Private Sub Combo1_LostFocus()
      bAlreadyDown = False
    End Sub
    
    
    Private Sub Command1_Click()
        Combo1.SetFocus
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width