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

WPF RadGridView - If Enter Key (But Value Not Changed) Act Like Escape Key

1 Answer 212 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 08 Feb 2018, 05:02 PM

When editing a cell in a RadGridView, the normal behavior for the escape key is to leave edit mode but retain focus on the same cell; if the enter key is pressed, to commit the edit and advance focus to the next editable cell.

My boss would like for me to modify the behavior so that if enter is pressed but the cell's value has not changed, to act as if it were the escape key instead. While I have been able to cancel the commit, but the focus still advances to the next editable cell, and that's not what he wants.

What is the best way to achieve what we're looking for? Thanks in advance for your help.

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 13 Feb 2018, 02:24 PM
Hi Barry,

The built-in mechanism through which such behavior can be achieved is the Custom KeyboardCommandProvider support of RadGridView. As in the implementation of the KeyboardCommandProvider you have the instance of the RadGridView to which it is applied, you should be able to apply to its BeginningEdit event so you can fetch the value of the cell that is currently about to be edited. Then, when the ProvideCommandsForKey method is triggered you should be able to determine whether to call the CancelEdit command or not. Can you please give the approach a try and let me know how it goes?

Best Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Barry
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or