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

Ignore enter key on non editable radGridView

1 Answer 132 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ken
Top achievements
Rank 1
ken asked on 29 Mar 2011, 04:07 PM
Hi there,

I have a command binding in my WPF form, it looks like this,
<UserControl.InputBindings>
      <KeyBinding Key="Enter" Command="{Binding Path=AddSelectedProductTypeCommand}"/>
  </UserControl.InputBindings>
I also have a grid that is non editable, however pressing the enter key causes a red outline to form around the grid, I suspect that it is grabbing the enter key press and then complaining cause IsReadOnly="True",

How can I tell the grid to ignore any key presses? Or just the enter key... I will take either.

Thanks

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 30 Mar 2011, 02:25 PM
Hello ken,
You may try cancelling command's execution, utilizing custom KeyboardCommandProvider:

testGrid.KeyboardCommandProvider = new MyCustomKeyboardCommandProvider(this.testGrid);
  
. . .
  
 public class MyCustomKeyboardCommandProvider : DefaultKeyboardCommandProvider
    {
        private GridViewDataControl parentGrid;
  
        public MyCustomKeyboardCommandProvider(GridViewDataControl grid)
            : base(grid)
        {
            this.parentGrid = grid;
        }
  
        public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
        {
            List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList();
            if (key == Key.Enter)
            {
                commandsToExecute.Clear();
            }      
            return commandsToExecute;
        }        
    }


Greetings,
Ivan Ivanov
the Telerik team
Tags
GridView
Asked by
ken
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or