This is a migrated thread and some comments may be shown as answers.

CustomKeyboardCommandProvider and Ctrl-Modifier

1 Answer 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 1
Markus asked on 04 Apr 2016, 04:08 PM

Hi,

I am having the following issue with my Custom KeyboadCommandProvider for RadGridView: If the user presses Ctrl+Down key, i want to select the third column of the next row. Therefore i move down once, check if Ctrl is pressed and if so, move to the first column and then twice to the Right. The problem is, that the Move-Commands also factor in the pressed shift key. Therefore the selection moves to the bottom of the list, then to the right and then twice to the end of the row. My code looks as follows:

public class ScheduleKeyboardCommandProvider : DefaultKeyboardCommandProvider
{
    private GridViewDataControl parentGrid;

public ScheduleKeyboardCommandProvider(GridViewDataControl grid)
: base(grid)
{
this.parentGrid = grid;
}

public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
{
List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList();
commandsToExecute.Clear();
bool ctrlIsPressed = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;

if (key == Key.Down)
{
commandsToExecute.Add(RadGridViewCommands.MoveDown);
if (ctrlIsPressed)
{
// move to first column and then move right twice
commandsToExecute.Add(RadGridViewCommands.MoveFirst);
commandsToExecute.Add(RadGridViewCommands.MoveRight);
commandsToExecute.Add(RadGridViewCommands.MoveRight);
}
}

return commandsToExecute;
}

}

 

I would appreciate some tips. Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 07 Apr 2016, 08:22 AM
Hi,

Can you consider selecting the third column with the following approach - Set the current cell?

Regards,
Yoan
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Markus
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or