We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GDBG simulate ESC click (Delete a row which is not saved yet)

Hi, I need GDBG support the following behaviour: Add new row to grid, while editing the new row, I want to remove the row. In this situation, when clicking cancel button, the new row is removed. this is OK. How can I simulate the ESC button click in code? I tried, binder.CancelEdit, grid.DeleteRowAtRowIndex, grid.CancelUpdate, but none of these has been worked. Any ideas? Thanks, GilK

1 Reply

AD Administrator Syncfusion Team January 13, 2005 01:03 PM UTC

Are you using teh AddNewRow at the bottom of the grid to let your user add the new row? If so, the default behavior is for the first esc to cancel the currentcell changes, and then the second esc cancels the row changes(if any), and if this is the AddNew row, it will remove it. If your user is in the middle of editing the AddNew row, pressing esc twice will delete it. You could try simulating this by: SendKeys.Send("{ESC}"); SendKeys.Send("{ESC}"); This should work as long as the grid has not lost focus. SO, having a menu item or toolbar button to trigger this is OK, but if it is Button on a form that triggers this, you woul dhave to set button1.CauseValidation = false to avoid thr grid losing focus when you click the button to trigget the action. If this does not work then I thing woul dwoul dhave to call grid.CurrentCell.EndEdit, grid.Binder.EndEdit and then grid.Binder.RemoveRecords. This would finish adding the record so it could then be removed. There are also DataTable.RejectChanges and DataRow.RejectChanges that can be used to do this as well.

Live Chat Icon For mobile
Up arrow icon