Hi all,
I'm using an UltraComboEditor as an editor in an UltraWinGrid to make a translation "Internal ID" <-> "User Key". The UltraComboEditor has a DataTabe as the DataSource:
ID Key100 1101 2102 3... ....201 100Entering data:DisplayMember ValueMember 1 -> 1002 -> 101 100 -> 100 WRONG201 -> 201 WRONG
What do I have to do the only Values in the key-list are accepted and correctly translated? DisplayMember ValueMember 1 -> 1002 -> 101 100 -> 201201 -> Not accepted
Hi Manuel,
What are the data types of these two fields?
You may be able to correct this behavior by setting the ItemMatchingMode property to disallow converting the ValueMember into a string - assuming it's numeric and it's not already a string.
Hi Boris,
Same problem, if I enter 100, your test succeeds, but in the value I have also 100 instead of 201. There might also be a list where the pairing 100 - 100 is correct, so I have to allowe it.
Is there an approach where I can eliminate the problem at the root, instead of trying to correct afterwards?
The clearest way is to force the UltraComboEditor to use only the display-members. Why does it consider the value-members anyway, I can't see the logic of it?
Manuel
Hello Manuel,
Please try the following modified code:
private void ultraGrid1_BeforeExitEditMode(object sender, Infragistics.Win.UltraWinGrid.BeforeExitEditModeEventArgs e) { if (ultraGrid1.ActiveCell.Row.Index == 0) { foreach (ValueListItem item in ultraComboEditor1.Items) { if (item.DisplayText == ultraGrid1.ActiveCell.Text) { isItemInList = true; break; } else isItemInList = false; } if (!isItemInList) { e.Cancel = true; } } }
Please do not hesitate to ask if something comes up.
Thank you for your quick reply. Your solution can solve a part of the problem, but only by correcting a wrong behaviour.In the case where I have 1 in the display which means 100 in the value, and I enter 100 I don't get a CellUpdate-Event, because the UltraCombo "thinks" there is already 100 and therefore no data change.
In my opinion there is a general design error: why does the UltraComboEditor look up in the value-members? Even more it looks first in the value-members, and then in the display-members!
Maybe there is a flag which limits the UltraComboEditor to consider only the display-members?
Regards
P.S: I'm using V 10.3 and V 11.2
Hello masch,
A possible approach to achieve this might be by hooking to the 'BeforeCellUpdate' event and do something like the following:
bool isItemInList = false; private void ultraGrid1_BeforeCellUpdate(object sender, Infragistics.Win.UltraWinGrid.BeforeCellUpdateEventArgs e) { foreach(ValueListItem item in ultraComboEditor1.Items) { if(item.DisplayText == e.Cell.Text) { isItemInList = true; break; } } if (!isItemInList) { e.Cancel = true; } }
bool isItemInList = false; private void ultraGrid1_BeforeCellUpdate(object sender, Infragistics.Win.UltraWinGrid.BeforeCellUpdateEventArgs e) { foreach(ValueListItem item in ultraComboEditor1.Items) { if(item.DisplayText == e.Cell.Text) { isItemInList = true; break; } }
if (!isItemInList) { e.Cancel = true; } }
Please feel free to let me know if I misunderstood you or if you have any other questions.