sfDataGrid.CurrentCellKeyDown +=sfDataGrid_CurrentCellKeyDown;
void sfDataGrid_CurrentCellKeyDown(object sender, CurrentCellKeyEventArgs e)
{
if(this.sfDataGrid.IsAddNewRowIndex(this.sfDataGrid.CurrentCell.RowIndex) && e.KeyEventArgs.KeyCode == Keys.Escape)
this.sfDataGrid.View.CancelNew();
}
|
void sfDataGrid_CurrentCellKeyDown(object sender, CurrentCellKeyEventArgs e)
{
if(this.sfDataGrid.IsAddNewRowIndex(this.sfDataGrid.CurrentCell.RowIndex) && e.KeyEventArgs.KeyCode == Keys.Escape && sfDataGrid.View.CurrentAddItem != null )
this.sfDataGrid.View.CancelNew();
} |
void sfDataGrid_CurrentCellKeyDown(object sender, CurrentCellKeyEventArgs e)
{
if (this.sfDataGrid.IsAddNewRowIndex(this.sfDataGrid.CurrentCell.RowIndex) && e.KeyEventArgs.KeyCode == Keys.Escape && sfDataGrid.View.CurrentAddItem != null)
{
if (this.sfDataGrid.CurrentCell.IsEditing)
this.sfDataGrid.CurrentCell.EndEdit(true);
var gridModel = ReflectionHelper.GetProperty(typeof(SfDataGrid), "GridModel").GetValue(sfDataGrid, null);
var addNewRowController = ReflectionHelper.GetProperty(gridModel.GetType(), "AddNewRowController").GetValue(gridModel, null);
var cancelAddNewMethod = ReflectionHelper.GetMethod(addNewRowController.GetType(), "CancelAddNew");
ReflectionHelper.Invoke(cancelAddNewMethod, addNewRowController, new object[] { });
}
} |