Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box expantion 5

Status
Not open for further replies.

dwlerwill

Technical User
May 25, 2001
329
Hi All

I have a combobox on my form and I want via code to autoexpand (As if you clicked the drop down arrow on the side) it once someone begins to enter text. I have searched the web and this forum but can not find anything. Anyone help?

David Lerwill
"If at first you don't succeed go to the pub"
 
Code:
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long

Public Sub DropDownCombo(cbo As ComboBox)
    Const CB_GETDROPPEDSTATE = &H157
    Const CB_SHOWDROPDOWN = &H14F
    If Not CBool(SendMessage(cbo.hwnd, CB_GETDROPPEDSTATE, ByVal 0, ByVal 0&)) Then
        SendMessage cbo.hwnd, CB_SHOWDROPDOWN, True, ByVal 0&
    End If
End Sub

Pass your combobox to the above function.
 
Hi bjd4jc,

I'm a newbee, so please be patient.

I added your code into a Module. How do I call this function?

---------------------------------------
This will be the day when all of God’s children will be able to sing with a new meaning, “My country, ‘tis of thee, sweet land of liberty, of thee I sing. Land where my fathers died, land of the pilgrim’s pride, from every mountainside, let freedom ring. - Marten Luther King
 
Presumming that you have a combobox named MyComboBox, you can call that function like this:

Code:
DropDownCombo MyComboBox

That's all.

Hope I've been helpful,
Bogdan Muresan.
 
bjd4jc,

This is just what I have been looking for, but did not find it for hours (many hours) over a period of months! Can this be posted under the heading of something like "Auto expand combobox" or "Auto dropdown combobox." This forum it the greatest. I hope that someday I may become proficient enought to give back some in return for all the help that this forum has given. [smile]

lrott
 
Code:
[Blue]

    SendKeys "{F4}"

[/Blue]

Use it like this

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

If you want to use it in any other event, (May be the click event of a command button)

Code:
Private Sub Command1_Click()
    Combo1.SetFocus
    SendKeys "{F4}"
End Sub

------------------------------------------
The faulty interface lies between the chair and the keyboard.
 
>the heading of something like "Auto expand combobox" or "Auto dropdown combobox."

A search in this very forum under "dropdown combo" will find bjd4jc's previous post of the same code provided here.

Keyword searching in this forum can be very productive.

Also, a request for automatic dropdown is often followed by a request for cha ging the number of items displayed in the dropdwon. thread222-438535 provideds a solution to this
 
This is off topic a bit, but I just had a heck of a time finding this thread thread222-1137029. I'm sure I put "findwindow" in there and couldn't find it, but now when I put it in it does find it. I probably put it in the top search box and went looking for a forum called findwindow or something. Anyway, I tried "enumchildwindows" and didn't find it. I'm concluding that the keyword search only looks in the OP post, not in the entire thread. Is this correct?

Bob
 
Bob-

I have found that google often has a better index of this site than the site itself. Perhaps you are correct about indexing only the original post.

This search in google provides the thread you referenced as the 5th entry on google: site: findwindow
 
Um, what was the exact string you used on google, please?

Thx

Bob
 
The search functionality of this site is something that has been needed an upgrade from years. I know it is on their to-do list, but it's a huge and complicated job. Many of the "old pros" here do just as bjd4jc suggested and use google to search the site.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
>>It has moved to the 9th entry now, though

Hmmm, this is strange, mine is still at the 5th entry.
 
Oh! The light dawns. I didn't know you could put a "site:" qualifier on google. Outstanding. Furthermore, I can get the same thread searching for enumchildwindows.

Mine is at the 5th entry too, btw.

Thanks bj and strongm, that will come in handy.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top