Hi
I have an ultracombo column on a grid. When I do the grids PerformAction(UltraGridAction.UndoCell) it does not set the combo item back to it's original value. Although, the value of the cell is set back to its original value when I look in code. For example:
I have a drop down with value like so
Value Member : Display Member
1 : One
2 : Two
say the value in the cell is currently 1 so the display reads One, I then choose Two but I have code to cancel that and also PerformAction(UndoCell) , what happens then is the cell shows value 1 but text 2 i.e:
1 : Two
How do I undo it properly?
Thanks
Paul
The undo operation has to occur while the cell is in edit mode since the grid does not keep track of these changes.
The best place to validate a cell is hooking cellchange. Alternatively you can just call e.Cell.CancelUpdate. eg. private void UltraGrid1_CellChange(object sender, CellEventArgs e) { if ((string)e.Cell.Text == "B") { e.Cell.CancelUpdate();
orultraGrid1.PerformAction(UltraGridAction.UndoCell); } }
Hi Michael
I was advised to do that in Before Exit Edit.
So, I am still in edit mode and both the choices above don't work when the cell is a combo, they work when it is just plain text. I have written some workaround to put the combo back to what it was. The first line below resets the cell value but the combo would stay on whatever the user had selected prior to UndoCell so I have to then set it back to what it was myself.
this.Grid.PerformAction(UltraGridAction.UndoCell); // Reset cell value if (args.Cell.EditorResolved is UltraGridComboEditor) args.Cell.EditorResolved.Value = args.Cell.Value; // undo doesn't work on combos so have to reset manually e.Cancel = true; // do not leave
If I get no further problems with it then i will probably just leave it as it is but it seems to me that it does not work like it should do.