Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
255
UltraCombo value member/displaymember when typing a value into cell
posted

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?

Parents
  • 469350
    Offline posted

    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.

Reply Children