Hi,
we have a grid (DataSource is a DataSet from a SQL-Query) with some Cells.
In the InitializeRow-Event we set the Value of a Cell (e.g. Class) to a new Value (e.g. "A").
The Values are displayed correct, but when the user hits "ESC" and the row is only Active and not in Edit-Mode the Value of the "Class"-Cell is resetted to "", which is the OriginalValue.
Is there any chance to prevent this behaviour, e.g. Accept the Value as OriginalValue?!?
When I set the Value twice Value and OriginalValue are the same and everything is ok, but that is not a solution...
Regards,
Wolfgang
Hello,
Pressing the Escape key will result in resetting the cell value, which is expected. To prevent this from happening you can cancel the action within the BeforeCellCancelUpdate event like so:
private void ultraGrid1_BeforeCellCancelUpdate(object sender, CancelableCellEventArgs e) { e.Cancel = true; }
private void ultraGrid1_BeforeCellCancelUpdate(object sender, CancelableCellEventArgs e)
{ e.Cancel = true; }
You can change what the escape key does when pressed, (eg. deactivate cell), like so:
void ultraGrid1_KeyUp(object sender, KeyEventArgs e) { var grid = (UltraGrid)sender; if (e.KeyCode == Keys.Escape) { // ExitEditMode grid.PerformAction(UltraGridAction.DeactivateCell); } }
void ultraGrid1_KeyUp(object sender, KeyEventArgs e) { var grid = (UltraGrid)sender;
if (e.KeyCode == Keys.Escape)
{ // ExitEditMode grid.PerformAction(UltraGridAction.DeactivateCell); } }
Please see my attached sample below, let us know if this is what you are looking for.