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
920
Problem with Cell.OriginalValue and ESC
posted

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

  • 29045
    Offline posted

    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;         }

     

    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);   
                      }        
    }


    Please see my attached sample below, let us know if this is what you are looking for.

    EscapeKeyNewValue.zip
  • 469350
    Verified Answer
    Offline posted

    Hi Wolfgang,

    After you set the value of the cell(s) in InitializeRow call e.Row.Update to commit the changes.