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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drop down list when start typing 1

Status
Not open for further replies.

aw23

Programmer
Nov 26, 2003
544
IL
I have a combobox. The way a combobox works is that if you start typing it starts displaying something from the list that matches. And if you click on the arrow it brings you the whole list. How can I do it so that when the user starts typing it also brings down the list without clicking the button?

Thanks
 
Isn't this a forms question (forum702)?

Perhaps in the on got focus event (when they enter the control)?

[tt]me!mycombo.dropdown[/tt]

Roy-Vidar
 
Thanks, that worked except that it drops as soon as it has focus. Sometimes I set it to focus and don't want it to drop. Is there any way to do it once the user starts typing?

Thanks
 
Allright I got it, on change.
Thanks!
 
The problem with that is that when I select something form the dropdown it also dropsdown. I don't want it to at that point. I just want it to populate.
 
He he - which is why i suggested the on got focus, it's a bit tricky making something like that work in the on change. It triggers per each keystroke you expose the combo to, and selecting.

Could perhaps use the .ListIndex of the combo to do some testing (-1 = no selection), so for instance to prevent the dropdown if there's alredy a selection, then in the gotfocus:

[tt]if me!mycombo.listindex=-1 then
me!mycombo.dropdown
end if[/tt]

Else, using the on change, I haven't bothered experimenting much with it, the gotfocus and listindex test is usually good enough. Perhaps play with the .Text and .Value property (.Text property will contain what's entered, but not yet "saved" to the combo in the on change - but will probably contain the "whole" text of the item matching the first entered letter, so I don't know).

Roy-Vidar
 
No, that doesn't work. Let's say I'm standing on something in the combobox and then I go to something else. I set focus to the combobox and it drops down, but I don't want it to! Is there any way???

Thanks
 
Strange, when I use the above code in the gotfocus, it behaves as it shold. "drops down" both when focus is set programatically or thru the tab sequence when theres no selection, but "stays" if there is a selection. Perhaps share the code?

If you're trying the on change event, as said, I don't know what kind of tweaking that would need. Hope someone with such experience pops in, but do state which it is you're working on. Just a thought, doing some form public thingie? and using the combos on keydown or something counting the characters pressed? Could that be an option? Would need to differensiate between valid letters/numbers (vbkeya-vbkeyz, vbkey0-vbkey9, vbkeynumpad0-vbkeynumpad9, vbkeyescape, vbkeyreturn, vbkeyback, vbkeydelete, vbkeytab...)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top