I currently have an UltraGrid that contains a column with an UltraCombo control.
ReferenceKey ObjectNumber
595 “639”
596 “640”
597 “641”
598 “644”
599 “645”
600 “646”
641 “727”
642 “728”
643 “729”
644 “730”
645 “731”
Above is the data set that is bound to the UltraCombo.
UltraCombo.ValueMember = “ReferenceKey”
UltraCombo.DisplayMember = “ObjectNumber”
When I start to type into the cell “6” then “4” it auto-fills the third char to “0” (which I understand because “640” is the first value in the list that matches the 6 and the 4 that I’ve typed).
However when I then type “3” (“643” is not a DisplayMember value) the combo resolves to the record with the ReferenceKey of 643…DisplayMember of “729”
Why is this UltraCombo using the ValueMember to resolve a “search” based on what I’m typing in for the DisplayMember?
Is there a particular property on the UltraCombo that I need to set to prevent this behavior?
Hi Jim,
You can fix this by setting the ItemMatchingMode on the UltraCombo to ValueListItemMatchingMode.DoNotConvertDataValueToString.
If you are interested in why this happens, here's a detailed explanation.
The UltraCombo (and all of the Infragistics WinForm Editor controls) architecture only allows for the storing of one piece of information - the Value.
In other words, the Combo does not store the Value and the DisplayText. I just stores the value and then converts that value into the DisplayText by matching the value to an item on the list and getting the corresponding DisplayMember field as needed.
So if the user enters some text that does not exist in the DisplayMember column, that value cannot be converted from DisplayText into a DataValue. What the combo does in this case is it just takes the raw text that the user enters and stores it as the Value. If that value then happens to match up to a value in the ValueMember column, it gets converted into DisplayText.
Setting the ItemMatchingMode in this case essentially prevents the Combo from recognizing "643" as a valid value in the ValueMember column since "643" is a string and the values in the ValueMember fields are integers.
But you should be aware that you now have an UltraCombo control whose Value property normally returns an integer, but in some cases will now return a string. So your code may have to account for that.
Thank you Mike for the prompt response to my issue!
However adding the ItemMatchingMode = Infragistics.Win.ValueListItemMatchingMode.DoNotConvertDataValueToString did not resolve the issue.
When I type in “643” in the cell and tab out it is still resolving to the “729” row (ValueMember of 643) when I tab out of the cell.
Is there possibly something else that we have coded “later” that could be overriding this behavior? I have searched our code base and found no other references to the ItemMatchingMode property anywhere.
Again thanks so much!
Hi,
I can't think of any other setting that would override this behavior. I created a small sample to make sure this worked before I replied to this thread. I'm attaching the sample here, which works for me, so you can see if it works on your machine. If it does not, then the problem must be in the version of the controls you are using, in which case, you might need to get the latest service release, or upgrade to a newer version. I think I recall that there were some bugs in this property in some older versions so maybe that explains it.
I went ahead and downloaded/installed 16.2 of the components I needed. I then changed all of the references to any/all components to 16.2.
So I know I’m up to date from a component perspective (BTW – the version of the components I’ve updated to are 16.2.20162.1000).
I have run my process with the “original” code (that is the grid’s dropdown .ItemMatchingMode set to “Infragistics.Win.ValueListItemMatchingMode.AllowConvertDataValueToString”).
I have also changed the grid’s dropdown to your suggested .ItemMatchingMode to “Infragistics.Win.ValueListItemMatchingMode.DoNotConvertDataValueToString”
Both of the properties above did not make any difference.
Is there any other way for me to "trace" the instance of the control between events of the control?
Thank you!
Okay... I think what I was missing here is that you are using a WinGrid here. My sample just uses an UltraCombo on a form.
I suspect I know why it's not working for you.
As I explained previously, when you type "643" into the UltraCombo, it doesn't match an item in the DisplayMember column. So it cannot convert this value into a corresponding ValueMember column value. So what the UltraCombo does in that case is that it store "643" as it's Value. Ordinarily, it would match "643" (string) with 643 (int) and match it up based on that, but the ItemMatchingMode prevents it from making that match from string to int so it works how you want. But the important thing to note here is that the Value of the UltraCombo at this point is a string, not an int.
The grid, however, has an additional limitation due to the column's DataType. The Value property on the UltraCombo can return a string. But your grid column's DataType is probably int, and therefore the data source for that column cannot store a string. It has to convert the string into an int or the data source will blow up. So it can't do what the UltraCombo does.
I am attaching here an updated version of my sample that uses a WinGrid. My grid has two columns. The first column (Column 0) is an int column. The second column (Column 1) is of type object.
If you type 643 into the first column and then leave the cell, it translate this into 729 - the same result you are getting. There's no way around this if the column's DataType is int because this column and it's data source cannot store strings.
If you type 643 into the second column and then leave the cell it works, because the cell's value can store a string.
I was finally able to get back to this issue.
Sure enough…changing the column to a string data type was the issue and it did indeed fix the problem.
Appreciate the assistance on this issue!
Jim