CustomKeyboardCommandProvider and Ctrl-Modifier

2 posts, 0 answers
  1. Markus
    Markus avatar
    9 posts
    Member since:
    Apr 2015

    Posted 04 Apr Link to this post

    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.

  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 07 Apr Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top