Hi,
I want to make validate code in AfterCellUpdate event and When user input 'Enter' key then KeyDown event catch it, purform AfterCellUpdate event.
This is code.
private void UltraWInGrid_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //Here, I want to invoke AfterCellUpdate event } }
When user input some keys on active cell and input 'Enter' key or click other cell, I want to handle with same validation.
What is best way? is there other good way to validate those case?
What you might want to consider is, rather than actually raising the event, you could simply call the event handler method directly.
Example:
this.ultraGrid.KeyDown += new KeyEventHandler(ultraGrid_KeyDown);
void ultraGrid_KeyDown(object sender, KeyEventArgs e){ if ( e.KeyData == Keys.Enter ) { UltraGrid grid = sender as UltraGrid; UltraGridCell activeCell = grid.ActiveCell;
if ( activeCell != null ) { CellEventArgs args = new CellEventArgs( activeCell ); this.grid_AfterCellUpdate( grid, args ); }
}}
void grid_AfterCellUpdate(object sender, CellEventArgs e){}