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
530
Cancelling AddRow
posted

I want to keep the focus in the AddRow when the user press Enter key in a Cell.  When the user click on the TemplateRow the grid create an AddRow, if the user then begin editing in a AddRow and press Enter key the grid move to the TemplateAddRow and automatically create another AddRow, how to prevent this?  I want to create an AddRow ONLY when the user clik on the TemplateAddRow.  Thanks.

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi,

    The grid's keyboard behavior is controlled by the KeyActionMappings collection. So to disable the Return key for committing a row, you have to loop through the collection and remove any key actions for CommitRow.

    In order to prevent the list for getting out of synch while looping through it and removing items, it's a good idea to loop through the list backwards.

    Here's some sample code that shows you how:

    for (int i = this.ultraGrid1.KeyActionMappings.Count - 1; i >= 0; i--)
                {               
                    GridKeyActionMapping keyActionMapping = (GridKeyActionMapping)this.ultraGrid1.KeyActionMappings[i];
                    if (keyActionMapping.ActionCode == UltraGridAction.CommitRow)
                        this.ultraGrid1.KeyActionMappings.Remove(keyActionMapping);
                }

     

Reply Children
No Data