CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2000
    Location
    Hong Kong
    Posts
    94

    How to list the items of Combo list when it get focus without click on it

    Hi:
    Here I have problem, I have a Combo list. If the user don't want to use mouse, and She want the Combo list list all of of it's item just like mouse click on it when she use TAB to focus on it. How can I implement this function. If anybody know about it. It will be very helpful
    Millions of Thanks.


    wky086

  2. #2
    Join Date
    Feb 2000
    Location
    Ireland
    Posts
    808

    Re: How to list the items of Combo list when it get focus without click on it

    If you want it to drop down when it has focus then your user can either hit F4 or in the gotfocus event you can put

    SendKeys "{F4}"



    which will automatically drop it down when it gets focus. The problem with that is that if the user uses the mouse to click on the combo then using the sendkeys will wffectivly cancel the drop down. Try it and you'll see


  3. #3
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: How to list the items of Combo list when it get focus without click on it

    Try this:


    Const WM_USER = &H400
    Const CB_SHOWDROPDOWN = &H14F
    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 Sub Form_Load()
    Combo1.AddItem "Mt. Everest"
    Combo1.AddItem "Mt. Annapurna"
    Combo1.AddItem "Mt. Kilimanjaro"
    End Sub

    private Sub Combo1_GotFocus()
    Call SendMessage(Combo1.hwnd, CB_SHOWDROPDOWN, true, 0&)
    End Sub





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

Featured