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!

How to search case insensitive for values in combobox in vfp 8.0?

Status
Not open for further replies.

diemtranrms

Programmer
Jun 5, 2015
7
VN
Hi Everyone,
I have a issue about search characters in combobox in vfp 8.0 and need support to solve this.
The description as following:
Place a combobox on the form. Store values from field in a table into array arrTemp. Set its RowSource property to arrTemp and its RowSourceType property to 5 – Array, Style 0- Dropdown Combo and IncrementalSearch .T. –True.
I enter value lowercase to combobox and then click dropdown. The combobox does not search to value which exist in the list of combobox and only hightlight with the first value. The below snapshot error
Non_-sensitive_combobox_l6aol8.png

Could you please help me to search value with case non-sensitive or incremental search in combobox vfp 8.0?
Thanks for your helps.
 
As far as I can see, this isn't an issue with case-sensitivity. In fact, the behaviour you are seeing is as expected.

If you are trying to search for Ann, then you need to type A, N, N fairly quickly. If you type too slowly, you will get the first A, then the first N, then the first N again. So the speed of typing is important. If you can't type fast enough, adjust the setting of the _INCSEEK system variable (see the Help for details).

Also, with a Style setting of 0, you have to be sure that the drop-down portion is open when you start typing. That's not a problem if Style is set to 2.

Edit: I'm not sure if INCSEEK was available in VFP 8.0. If it's not, use _DBLCLICK instead. It's the same concept.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
What Mike explains is one true issue, you need to search fairly quickly, also, you have most probably set up the combo box style to be a dropdown combo, not a dropdown list. Incremental search does not work if you can type into the textbox part of the combo box. If you want this behavior you have to LOCATE data, or if you want to make use of incremental search configure the style to be dropdown list. How fast you need to type depends in _INCSEEK, as Mike said. I am quite sure that distinction of _INCSEEK and _DBLCLICK already existed in VFP7.

But if you rather want to let the user type, then LOCATE or INDEXSEEK or maybe also SET FILTER yourself in InteractiveChange or when the drop down button is clicked, that would mean in the DropDown() event. Use This.DisplayValue as the text searched.

Bye, Olaf.
 
It seems that the issue does not depend in _INCSEEK variables.
My expected can search a value in list combobox after I click dropdown.
(when user types lowercase characters and then click dropdown, the result search will highlight to uppercase characters which exist in list of combobox, not hightlight the first value).
Besides, I used InteractiveChange, DropDown proceduce and this.Displayvalue as text searched, but the result search does not expect.
For example: Attached is below image with the values list in combobox is LastName field from Employee table.
Non_-sensitive_combobox1_xjbiwy.png
 
I'm not seeing what you are seeing. I've searched with Style = 0 (and the drop-down portion open) and Style = 2, and in both cases the search is definitely case-insensitive.

You wrote:
I used InteractiveChange, DropDown proceduce and this.Displayvalue as text searched,


I'm not sure what that means, but I suspect that might be the problem. With an incremental search, you don't need to do anything in code to initiate the search.

Try removing the code from your InteractiveChange and DropDown events. Then just open the drop-down list manually, and do the search again. Does it now work?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Nobody said _INCSEEK is the core of the problem. Incremental search does not work if you can type into the textbox part of the combo box, because you then just write into the textbox INSTEAD of choosing an item of the listbox items. That's the mode of the combobox by design, the textbox is then meant to be your input of a new text, an alternative Item, it's not a search box.

If you always want incremental search you have to set the style to dropdown list, then you don't first need to activate the dropdown button.

Bye, Olaf.
 
Yes, I have removed the code from your InteractiveChange and DropDown events. And search result as previous attached image.

As requested, I must set the style to dropdown Combo and search an item which is typed textbox part of the combo box and click down arrow
dropdown_cfnrip.png
, the result will search to item (highlighting) that I just have typed, does not distinguish lowercase or uppercase.

Steps by steps to reproduce the issue.
1.Create a new form, and place the following code in its Load event procedure
PUBLIC ARRAY aTitle(1)
SELECT DISTINCT(employee.last_name) FROM employee ;
INTO ARRAY aTitle
2. Add the employee table from the Visual FoxPro 8.0: \Samples\Data to the Data Environment of the form.
3. Place a combo box on the form. Set its RowSource property to aTitle and its RowSourceType property to 5 – Array, Style 0 – Dropdown Combo and IncrementalSearch.T. – True
4. Run form
5. User types data with lowercase letters which is one of the values in aTitle array into the combobox, then click down arrow.

Observed Behavior: unable to search item in the list items with lower case (not highlighting to the matching data). As an example,user types: davolio - not search and highlighting to Davolio, but user types: Davolio – search and highlighting to Davolio.
Expected Behavior: Enable to search the drop downs with lower case. user types: davolio- search and highlighting to Davolio.

I have spent a lot of time to fix this issue, Could you please detail support about this?
Thanks a lot MikeLewis and OlafDoschke.
 
Well, as we said, this behavior is not what the combo box offers. Incremental only works in Dropdown Combo mode.
If all you want to be able with the textbox part of the Dropdown Combo mode is to search the entered value, then simply don't do it that way, set the style to Dropdown List and you're done.

Bye, Olaf.
 
Incremental only works in Dropdown Combo mode.

Just for the record, incremenatal search also works in Dropdown List mode, provided the dropdown portion of the control is open.

But that doesn't alter the underlying fact: no matter how you set things up, the search is always case-insensitive.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, Mike, but as diemtranrms wants this to work without first clicking the drop down button, it has to be a Dropdown List combobox. Or you need to first click.
Or you need to program something, which you advised to not do and revert, you ruined my advice this way.

I partly agree, as the functionality works without code, but if you explicitly want to not incrementally search, but at the click, then you have to program code in the dropdown event.

So to summarize and be pedantically correct here: If you want to use the incremental search feature you either have to use dropdown list style or when using dropdown combo style need to get used to first click the dropdown button. That's the two modes of incremental search. Everything else needs your own code.

It now just depends on whether you want to make use of the built-in incremental search or don't care about it and want to implement your idea of the UX with user typing in the textbox part. Then you need code and can't make incremental search work as some kind of late bound hook. Incremental search means it works incrementally, not as one search at one instance, but with every key you type, It can only work, if the keys you type directly influcence the selected item, because alternative a) there is no textbox accepting your input or alternative b) the list is dropped down and has become the part of the control having focus, also not accepting input but instead incrementally move to the item beginning with entered keys. While this is working, you never see what you typed nor is it highlighted in the active item. Because of this and other flaws like the need to type fast enough, though you don't see what you typed already, is making your approach attractive, but you can't make use of the feature, then.

So overall your expectation is not happening and that's not just because you miss one setting. Either you steer towards the way incremental search really works or you roll your own search. Both viable options. If you want the latter, you can go back to what I recommended to do, mainly using own code in the DropDown event, I pointed out you need This.DisplayValue to know what the user typed in. Then disregard Mikes advice not to do so. If you want to make use of incremental search get used to it working differently than you think.

My advice for simplicity of it, make your combobox a dropdown list style combobox, then it just needs focus and typing on it changes the active item. When you're there you even don't need to drop down the list, you already picked the item by typing instead of clicking. It's a keyboard friendly interface, if you also know to navigate between controls by tabbing, you can use this and normal textboxes, other controls also have means to use them by keyboard only. And that makes the big advantage to keyboard loving users, not typing and clicking. Therefore I argue the way it is is better than the way you expect it to be.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top