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

KeyDown event not triggering on arrow up and down

1 Answer 409 Views
GridView
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 26 Mar 2014, 05:25 PM
If I type a letter it goes to the event, but not the arrow keys.

KeyUp does catch the arrow keys, so that's what I'm going to use


I'm basically doing this to put things in edit mode on the arrow up and arrow down:
private void handleArrows(object sender, KeyEventArgs e)
{
    RadGridView rgv = (RadGridView)sender;
    if (e.Key == Key.Down)
    {
        RadGridViewCommands.MoveDown.Execute(null);
        rgv.BeginEdit();
        e.Handled = true;
    }
    if (e.Key == Key.Up)
    {
         RadGridViewCommands.MoveUp.Execute(null);
        rgv.BeginEdit();
        e.Handled = true;
    }
}

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 28 Mar 2014, 12:40 PM
Hi Dan,

indeed, the KeyDown event will not be raised because GridView handles it internally.  In order to use it you have to subscribe to it with HandledEventsToo set to true. Please check the following code snippet for a reference:

this.gridView.AddHandler(RadGridView.KeyDownEvent, new KeyEventHandler(gridView_keyDown), true);
                   .
                   .
                   .
private void gridView_keyDown(object sender, KeyEventArgs e)
       {
           RadGridView rgv = (RadGridView)sender;
           if (e.Key == Key.Down)
           {
               RadGridViewCommands.MoveDown.Execute(null);
               rgv.BeginEdit();
               e.Handled = true;
           }
           if (e.Key == Key.Up)
           {
               RadGridViewCommands.MoveUp.Execute(null);
               rgv.BeginEdit();
               e.Handled = true;
           }
       }

 



Regards,
Yoan
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
GridView
Asked by
danparker276
Top achievements
Rank 2
Answers by
Yoan
Telerik team
Share this question
or