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

Combobox like Google's?

Status
Not open for further replies.

Apata

Programmer
Apr 5, 2006
52
US
Hi:

I would like to make a Combobox like Google's, using VFP 9. I want the Combobox to do the following:

1. Open up after the first character is typed, but not before, and stay open until done.

2. Do an incremental search on the string as more characters are typed.

3. Resize the width of the Combobox if length of string typed is wider.

4. Constrain the depth of the Combobox to about 10 rows when it opens up.

Thanks.

Apata
 
Apata,

This is easy. Don't use a combo box. Use a textbox. Set its Autocomplete property set to 1 (or 2 to 4, depending on your tastes).

I'm not sure if that exactly mimics Google (in fact, I'm not sure what you mean by Google's combobox), but it probably comes close.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi, Mike. I was referring to the search combo box on the Google Toolbar.

I am trying to get the incremental search on a field containing names. How would I use your suggestion with the textbox and how would it open up with more names matching what's typed?

Thanks.
 
Apata,

open up help and learn about the autocomplete feature. Start at the Autocomplete Property of the textbox mike told you about.

Autocomplete uses a table to store already typed strings and you can make that a local table for each user or a global one, you can predefine values searchable, the table will be extended by each value typed in (if it didn't lead in a final selection of an already known item) and you're even able to define several things about how and what items are suggested by autocomplete, eg by the frequency, with which items are reused.

Would take a whole article or at least a FAQ to explain all features available.

It really fits all your needs you gave us and more.

Bye, Olaf.
 
Apata,

sorry, "all of your needs and more" is a bit misleading. You'd still need some code to resize the textbox, but that's the only feature which would normally break a form design and so isn't a basic feature of autocomplete.

You might simply adjust the width of the textbox in the interactivechange to
a) still fit the form width minus some margin pixels.
b) be at least thisform.textwidth(this.value)

Bye, Olaf.

Mike: take a look at
 
Apata,

How would I use your suggestion with the textbox and how would it open up with more names matching what's typed?

It just works. You don't have to do anything other than setting the property I mentioned.

It's true that it's not a combo. There's no arrow to click on. But you do get the drop down list which updates itself as you type.

I use this in my own search forms, and it works fine. But I also give the user the option of turning it off in case they prefer to do without it.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Apata

Take a look at faq184-1792.

It behaves almost like you want. Except it does not open up.

1. Open up after the first character is typed, but not before, and stay open until done.

It does that.

2. Do an incremental search on the string as more characters are typed.

It does that.

3. Resize the width of the Combobox if length of string typed is wider.

If the value is not in the list, it will ask you to save it.

4. Constrain the depth of the Combobox to about 10 rows when it opens up.

To limit the quantity of items displayed in the list, you need to specify the columncount to 1, the rowsourcetype to array, and set the numOfElements property to however many items you want to display.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thanks guys! I appreciate all your help. Have been away for the Christmas and New Year break. Wishing you all a wonderful New Year!

Apata
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top