Click to See Complete Forum and Search --> : How to list the items of Combo list when it get focus without click on it


wky086
May 29th, 2001, 04:53 AM
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

TH1
May 29th, 2001, 05:02 AM
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

shree
May 29th, 2001, 06:41 AM
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