Hello,
We want to use the enter key to traverse between the cells in the row of a RadGridView, this works fine at the moment only the transition to the next row is a problem.
We want the RadGridView to behave as follows,
- When the last cell is reached, a enter will commit the changes in the last cell without creating a new row;
- If the user gives another enter, a new row is created and focus is traversed to the first editable cell in the new row.
We have created a CustomKeyboardCommandProvider as suggested in this blog post.
The function ProvideCommandsForKey(..) is only called for the first enter, then the keyboardfocus is moved out of the grid while the last cell has still some sort of focus, a rectangle is shown in the cell, but it doesn't respond on the keyboard enter presses anymore. We tried using commands to select the cell or row after the commit but these are not working, the focus is still leaving the grid after the commit is done.
public
override
IEnumerable<ICommand> ProvideCommandsForKey(Key key)
{
List<ICommand> commandsToExecute =
base
.ProvideCommandsForKey(key).ToList();
/* IF Enter key is pressed and we are in the last cell */
if
(key == Key.Enter && (_parentGrid.CurrentColumn.DisplayIndex == _parentGrid.Columns.Count - 1))
{
if
(_firstEnterHandled ==
false
)
{
_firstEnterHandled =
true
;
commandsToExecute.Clear();
commandsToExecute.Add(RadGridViewCommands.CommitCellEdit);
commandsToExecute.Add(RadGridViewCommands.SelectCurrentUnit);
// DOESNT WORK
}
else
{
commandsToExecute.Clear();
commandsToExecute.Add(RadGridViewCommands.BeginInsert);
/* Reset flag */
_firstEnterHandled =
false
;
}
}
else
{
/* Reset flag */
_firstEnterHandled =
false
;
}
return
commandsToExecute;
}
Any help would be appreciated.
Marcel