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

responding to the enter key

2 Answers 215 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 19 May 2011, 02:05 AM
I'd like to respond to the enter key when a row is highlighted.  i.e. select the row using the arrow keys, then hit enter and essentially duplicate the functionality of the doubleclick action grabbing the row.datacontext like so:

private void GridViewImportTransactions_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement originalSender = e.OriginalSource as FrameworkElement;
            if (originalSender != null)
            {
                var row = originalSender.ParentOfType<Telerik.Windows.Controls.GridView.GridViewRow>();
                if (row != null)
                {
                    //MessageBox.Show("The double-clicked row is " + ((PacerImportTransaction)row.DataContext).ID);
                    RawDataWindow _rawDataWindow = new RawDataWindow(((PacerImportTransaction)row.DataContext));
                    _rawDataWindow.ShowDialog();
                }
            }
  
        }

how do I do that?

Jonathan

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 20 May 2011, 10:16 AM

Hi Jonathan,

You could subscribe to the RowActivated event of the RadGridView. It is fired by double-clicking on the row or by pressing the Enter key, the value of the row could be found in e.Row:

private void playersGrid_RowActivated(object sender, Telerik.Windows.Controls.GridView.RowEventArgs e)
{
      var dataContext = e.Row.DataContext;
}

You could find helpful this blog post about how ho change the default keyboard behavior.

In order to change the current functionality of the Enter key (that is to move the selection to the next row), you should define a CustomKeyboardProvider. I am attaching a sample project showing how to change the behavior of the Enter key so that it behaves as double click does.

I hope that this answers your question.

Greetings,
Didie
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jonathan
Top achievements
Rank 1
answered on 20 May 2011, 05:04 PM
Hi Didie,

thanks very much I'll give it a go
Tags
GridView
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Jonathan
Top achievements
Rank 1
Share this question
or