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

Do not enter edit mode on enter/arrow keys

1 Answer 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 24 Feb 2016, 01:20 PM

Hi!
Is there a way to _not_ enter the edit mode if the user changes the selected cell using the arrow keys or by pressing enter?
(Event if the user was in edit mode before). I want to get closer to the behavior of excel.

Alex

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 29 Feb 2016, 09:53 AM
Hello Alex,

For this requirement, you can benefit from the KeyBoard Command Provider mechanism which RadGridView supports. Basically, within the overriden ProvideCommandsForKey() method, you can implement logic as suggested in the snippet below.
public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
{
    List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList();
 
    if (key == Key.Enter)
    {
        commandsToExecute.Clear();
        this.parentGrid.CommitEdit();
    }
    if (key == Key.Tab)
    {
        commandsToExecute.Clear();
        this.parentGrid.CommitEdit();
    }
    return commandsToExecute;
 
}

Can you please give the suggestion a try and let me know how it goes?

Best Regards,
Stefan X1
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Alexander
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or