Keyboard mapping

Posted by: Luis.Alvarez on 18 July 2018, 4:21 am EST

  • Posted 18 July 2018, 4:21 am EST


    My application requires that when the Enter key is pressed on a cell the entry just made is accepted and the cell to the right is then selected. I initially used the _KeyDown event but couldn't get it to work. Looking in this forum it was suggested to use keyboard mapping. I implemented a keyboard mapping function for the Enter key to call my Event Handler which selects the cell to the right. However, when I select a cell, type a number and press Enter the the cell to the right is selected but the number is not accepted and my _EditEnd Event handler is not invoked. Is there a way to map the Enter key to invoke the _EditEnd and then invoke my EventHandler? Mapping the Enter key to the CommitInputNavigationTabNext causes an exception if my other keyboard mapping is present. I need for the number to be accepted and the cursor to move to the right when the Enter key is pressed. And if the end of the sheet is reached the cursor needs to skip a couple of rows and be positioned on the 4th row 1st column.

  • Marked as Answer

    Replied 18 July 2018, 10:53 pm EST

    Hi Luis,

    You would need to remove the KeyMap for Enter key first. Please use the code as follows:

      gcSpreadSheet1.View.KeyMap.Remove(new KeyStroke(Key.Enter, ModifierKeys.None));
    gcSpreadSheet1.View.KeyMap.Add(new KeyStroke(Key.Enter, ModifierKeys.None), SpreadActions.CommitInputNavigationTabNext);

    Also to customize the behavior you need to catch the Enter key event and set the active cell:

        gcSpreadSheet1.KeyUp += GcSpreadSheet1_KeyUp;


    private void GcSpreadSheet1_KeyUp(object sender, KeyEventArgs e)
    if(e.Key == Key.Enter)
    if(gcSpreadSheet1.ActiveSheet.ActiveColumnIndex== gcSpreadSheet1.ActiveSheet.ColumnCount-1)
    gcSpreadSheet1.ActiveSheet.SetActiveCell(gcSpreadSheet1.ActiveSheet.ActiveRowIndex + 2, 0);


    // throw new NotImplementedException();

    Deepak Sharma
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels