Ticket Q467204
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Detect when ENTER key is pressed in a grid

WPF - Detect when ENTER key is pressed in a grid

created 11 years ago

[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?

Answers approved by DevExpress Support

created 11 years ago (modified 11 years ago)

Hi Isaac,
I have attached a sample project illustrating how to accomplish this task. Please take a moment to review it.
Thanks,
Elliot

    Show previous comments (1)
    DevExpress Support Team 11 years ago

      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.

        Thanks Ilya, handling PreviewKeyDown event is fine for my purpose.

        DevExpress Support Team 11 years ago

          You are welcome!

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.