Home Forums WinForms controls Xceed Grid for WinForms the cell event ? Reply To: the cell event ?

User (Old forums)
Post count: 23064

Manipulating the data with the keyboard: you can press the <b>F2</b> key to edit a cell value. When editing a cell, you can press <b>Enter</b> to confirm fill in the value in the cell, or <b>Esc</b> to cancel the editing.

About the shifting of the focus: before the update, you should store the index of the row and column of the current cell in 2 variables, and after the update, you should set the current cell back, like this:
<code>// before update:
int rowIndex, columnIndex;
if (grid.CurrentRow is Xceed.Grid.DataRow) rowIndex = grid.DataRows.IndexOf((Xceed.Grid.DataRow)grid.CurrentRow);
else rowIndex = -1;
columnIndex = grid.CurrentColumn.Index;

// after update:
if (rowIndex >= 0 && rowIndex < grid.DataRows.Count) grid.CurrentRow = grid.DataRows[rowIndex];
if (columnIndex >= 0 && columnIndex < grid.Columns.Count) grid.CurrentColumn = grid.Columns[columnIndex];

Imported from legacy forums. Posted by Tommy (had 270 views)