[DevExpress Support Team: MOVED FROM Detect when ENTER key is pressed in a grid]
[I need to detect when the enter key is pressed in a grid view. Subscribing to the keydown event, I can get all the other keypress events but the event is not triggered when pressing the ENTER key. The grid that I'm displaying is readonly mode]
How can this be done in WPF?
We have closed this ticket because another page addresses its subject:
Detect when ENTER key is pressed in a gridWPF - Detect when ENTER key is pressed in a grid
Answers approved by DevExpress Support
Hi Isaac,
I have attached a sample project illustrating how to accomplish this task. Please take a moment to review it.
Thanks,
Elliot
Hello Jan,
Elliot's approach is based on handling the following TableView events: RowUpdated and HiddenEditor. These events are raised when an active cell is closed. In fact, this happens when an end-user presses Enter.
Although, there is another approach to accomplish this task using the standard WPF Preview_ events:
XAML...
<dxg:GridControl.View>
<dxg:TableView PreviewKeyDown="OnPreviewKeyDown" ... />
</dxg:GridControl.View>
C#void OnPreviewKeyDown(object sender, KeyEventArgs e) {
if(e.Key == Key.Return) {
// ...
}
}
I hope you will find this information helpful. Let me know your results.