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!

How to search and return all possible result as yout type? 2

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
585
PH
Hi everyone, im still enhancing my project... i have a combobox used with seek and if found() that you could search through scrolling the list, and clicking once you have found your search, my question is, is it possible to search by typing for example surname and returns possible searches while you tpe the letter? If so, please help me how to do it or show example that I coud base on? Thanks in advance...
 
The simplest is to set combobox.incrementalsearch=.t. and no code at all. The combobox then does react to what you type while it has focus, as long as you type fast enough. What is taken as start of the name you search, is everything you type with pauses shorter than .5 seconds, which is set in the _INCSEEK system variable (so you can also make it higher for people typing slower).

The _INCSEEK maximum pause time means that if you type MA to search for names starting with MA, but need more than _INCSEEK seconds between M and A, the search does not look for MA but for A. Or in other words, when you make a longer pause than _INCSEEK while typing, this means you start a different search.

Also important: This works for combobox.Style=2 (dropdown list) mainly, when the combobox is a dropdown list. With Style 0 you have a combination of a textbox with an item list and what you type simple goes into the textbox portion of this combined control and causes no incremental search, unless you FIRST expand the list and then type.

On the other hand, with the Style 0 (dropdown combo) you could use what you have with SEEK (when you also have SET NEAR ON to find the nearest match).

Does that help, or do you struggle with displaying the list while the user searches? There also is an example how to do all that in the solutions.app of VFP called "Allow users to choose list values", a solution about the combobox.


Chriss
 
Mandy,

Chris has given you a good answer - and the one that I would go for as well.

However, there is another option for you to consider. Instead of a combo box, use a textbox, and set its AutoComplete property to 1. Then, as you type each character, you will see a drop-down list containing all the entries you have previously made in that control which match the characters entered so far. You will then be able to select one of those entries without having to type the rest of it.

The main difference between this method and a combo box is that a combo box lets you select from a pre-determined list, such as an existing lit of customers, whereas the textbox method lets you enter any text - and will save that text for future use. (I mean that it saves it within the AutoComplete list, not that it saves it in a database.)

This might not be want you want, but I thought I would mention it for you to consider - either now or for some future requirement.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mandy, Mike

the autocomplete textbox is a usable alternative, correct. I'd prefer a fixed list for picking, but indeed you can also define the autocomplete data and set it up to not store further new texts typed in. It's just not as easy as with a combobox.

I still prefer the combobox dropdown list for that reason. The UI is more guiding, since you see a dropdown button you see there is a dropdown list, the textbox with autocomplete feature only shows that list when you begin typing. Ok, it may be early enough to understand it and only is an issue for a first time users hesitating what to type in without knowing a list of values to pick from. Whether you would hesitate also depends on what input the control wants from the user. If you ask for an address, nobody would expect or even welcome a dropdown list of streets or zip codes. Though in the case of zip codes it would help to guarantee only valid existing zip codes are entered.

If you want to use the autocomplete feature, you have to understand some implications. For a starter you could simply set Autocomplete=1 and see what happens. But you'd not easily get it controlled by a predefined list. a DBF is created and where that is and whether that will be a DBF per user or for all users will depend, so it's not the easiest option, that surely is simply setting incrementalsearch to .T.

Chriss
 
Thanks myearwood... ok, I'll try to study more...

Mike and Chriss Thanks so much... my app is now working well with these solutions and tips that you have given... god bless....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top