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

Combo Box Question - Is it possible to incremental search more then one column on drop down???

Status
Not open for further replies.

networkthis

Programmer
Jul 11, 2011
29
US
Is it possible to have a combo box with two columns and search both columns. We have two columns in this combo - both columns are stored as character fields. Example:

0001 | Description 1
0002 | New Description 2
0046 | Another Description

Column 1
While in the dropdown - we would like to be able to enter the numeric values stored as characters to set the listindex to the first column, but if the user enters a character description we would like it change the listindex based on the column 2 description?

I have tried several things, but keep coming up short.... Any ideas would be greatly appreciated!! Thanks
 
>Is it possible to have a combo box with two columns and search both columns
Incremental search can be turned on and off and works on column1 always and that's it. So you can't do that with incremental search, but what is complicated about doing what you want on your own?

Keypress event could be used.

You could use the combobox in combo mode, so the user can enter anything in the textbox portion and you can use that to filter or locate in col1 or col2 in InteractiveChange event.

That's just two options.

Bye, Olaf.
 
The thread that Nigel referenced describes a nice custom control that might be worth considering.

However, if you have a good reason for sticking with the native combo box, you might try the following:

1. Switch off the IncrementalSearch property.

2. Trap the user's keypresses.

3. Programmatically search column 1 or column 2 (depending on whether the first key is numeric); you can do that by looping through the List array property.

4. If you find a possible match, set the ListIndex to the corresponding row.

But be aware that, with a large list, this might be slow-ish. Also, your logic would have to take account of all the possible keys, including cursor control keys, backspace, etc. - not to mention pasting from the clipboard. But it might be worth thinking about.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top