I have a grid (non-databound) that I'm manually populating from a DB.
I want to save changes back to the DB at the appropriate time...essentially, when a cell has changed and we've moved to a new row, or the grid has lost focus.
What event would be the best to handle my save routine?
I don't want to save back to the DB everytime a cell is changed.
How do I best duplicate the datbound grid's behavior of undoing a given row's changes: ex., change cell 2 in row 3, then change cell 3 in row 3, then hit escape, reverts cell 3, hit escape again, reverts the row. BUT.... change cell 2, row 3, move to row 4, change cell 3, 1st escape key changes cell 3 back, but 2nd does nothing.
ADAdministrator Syncfusion Team August 11, 2003 04:42 PM
If you want this GridDataBoundGrid-like behavior, it might be simpler to use the GridDataBoundGrid.
You can use the CurrentCellMoved (or CurrentCellMoving) event to decide when you are changing rows. You can test grid.CurrentCell.MoveToRow and grid.CurrentCell.MoveFromRow to decide whether you are changing rows.
To handle the Esc requirement, I think you will have to buffer the old values for the changes on a row. You can use the same CurrentCellMoved event to decide when you want to reset your buffer. You can use, maybe CurrentCellValiding to populate your buffer. You could handle CurrentCellKeyDown to catch the Esc key to undo your changes. You could set a flag to track whether you get 2 escapes back to back for teh same row.