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

Enter key act like Tab key

1 Answer 159 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Karel
Top achievements
Rank 1
Karel asked on 06 Mar 2017, 08:55 AM

Hi, I am trying to change Enter key bevavior to act like Tab key. I found your documentation and blog post but these are all for the case when grid is in edit mode. My grid looks like this:

01.<telerik:RadGridView Name="Grid"
02.                             Grid.Row="1"
03.                             AutoGenerateColumns="False"
04.                             ItemsSource="{Binding Orders}"
05.                             ShowGroupPanel="False"
06.                             RowIndicatorVisibility="Collapsed"
07.                             BorderBrush="Black"
08.                             Margin="5">
09.            <telerik:RadGridView.Columns>
10.                <telerik:GridViewDataColumn Header="Price" Width="150">
11.                    <telerik:GridViewDataColumn.CellTemplate>
12.                        <DataTemplate>
13.                            <telerik:RadNumericUpDown Value="{Binding Price, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" SmallChange="0.1" LargeChange="1"/>
14.                        </DataTemplate>
15.                    </telerik:GridViewDataColumn.CellTemplate>
16.                </telerik:GridViewDataColumn>
17. 
18.                <telerik:GridViewDataColumn Header="Volume" Width="*">
19.                    <telerik:GridViewDataColumn.CellTemplate>
20.                        <DataTemplate>
21.                            <telerik:RadNumericUpDown Value="{Binding Volume, Mode=TwoWay, StringFormat=N2, UpdateSourceTrigger=LostFocus}" SmallChange="0.1" LargeChange="1"/>
22.                        </DataTemplate>
23.                    </telerik:GridViewDataColumn.CellTemplate>
24.                </telerik:GridViewDataColumn>
25.            </telerik:RadGridView.Columns>
26.        </telerik:RadGridView>

 

And my custom keyboard command provider looks like this:

01.public class CustomKeyboardCommandProvider : DefaultKeyboardCommandProvider
02.    {
03.        public CustomKeyboardCommandProvider(GridViewDataControl grid) : base(grid)
04.        {
05.        }
06. 
07.        public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
08.        {
09.            if (key == Key.Enter)
10.            {
11.                var tabCommands = base.ProvideCommandsForKey(Key.Tab).ToList();
12. 
13.                return tabCommands;
14.            }
15. 
16.            return base.ProvideCommandsForKey(key).ToList();
17.        }
18.    }

 

Is there a way how to do it for my case?

Thank you.

Karel

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 08 Mar 2017, 04:38 PM
Hello Karel,

Could you confirm that you've set the KeyboardCommandProvider property of your RadGridView to a new instance of your CustomKeyboardCommandProvider class? Doing so results in the expected behavior at my end.

this.Grid.KeyboardCommandProvider = new CustomKeyboardCommandProvider(this.Grid);

I'm attaching a sample project as a demonstration. Please let me know if I'm missing something of importance.

Regards,
Dilyan Traykov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Karel
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or