Results 1 to 5 of 5

Thread: [RESOLVED] ComboBox Display

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    203

    Resolved [RESOLVED] ComboBox Display

    How can I make a ComboBox open in a gotfocus event?

    I want the list to be displayed programaticly as if the down arrow was clicked.
    I am almost sure I used to do this but I can't remember what it was that I did.

    Any help is appreciated.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: ComboBox Display

    I never did understand why the ComboBox control does not have a simple method to dropdown its own list.

    Anyways, use the SendMessage API

    Code:
    'In a Module
    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
    
    'Form 
    Private Sub Combo1_GotFocus()
        SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 1, 0
    End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    203

    Re: ComboBox Display

    Thanks, it works great. Apparently I didn't use to do this.

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: [RESOLVED] ComboBox Display

    Perhaps you used

    Code:
    Private Sub Combo1_GotFocus()
        SendKeys "{f4}"
    End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    203

    Re: [RESOLVED] ComboBox Display

    I don't recall it being the SendKeys command.

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