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

How to navigate to next item on commit?

3 Answers 123 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Karl B
Top achievements
Rank 1
Karl B asked on 23 Mar 2021, 02:04 PM

While editing a value I want to be able to tab to the next item in the grid.  Currently this requires two tabs- the first one commits the edit and the second press to navigate. How can I change this behavior?

I am using RenderMode Flat.

I would accept navigating to the next item on Enter key as well as Tab if it makes the solution easier.

3 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 26 Mar 2021, 08:52 AM

Hello Karl,

What I can suggest in order to achieve the desired result is to handle the PreviewKeyDown event of the control in the following manner:

		public void OnPreviewKeyDown(object sender, KeyEventArgs args)
		{
			if (args.Key == Key.Tab)
            {
				this.rpg.CommitEdit();
				(RadPropertyGridCommands.MoveToNext as RoutedUICommand).Execute(null, this.rpg);
				args.Handled = true;
            }
		}

Note that "rpg" refers to the instance of the RadPropertyGrid control. Please let me know whether such an approach would work for you.

Regards,
Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Karl B
Top achievements
Rank 1
answered on 29 Mar 2021, 02:16 PM

This soultion did not work for me. Not only does the commit not happen when I press tab, but the next item in the property grid becomes highlighted but the previous text box still has keyboard focus. 

If it matters my dll version is 2017.2.614

 

0
Accepted
Dilyan Traykov
Telerik team
answered on 31 Mar 2021, 03:03 PM

Hi Karl,

Please excuse me for the misunderstanding. The proposed solution will only work when using the Single EditMode.

If you're using the Default EditMode, you can define the handler as follows:

        public void OnPreviewKeyDown(object sender, KeyEventArgs args)
        {
            if (args.Key == Key.Tab)
            {
                (RadPropertyGridCommands.MoveToNext as RoutedUICommand).Execute(null, this.rpg);
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    this.rpg.BeginEdit();
                }), System.Windows.Threading.DispatcherPriority.Input);
                args.Handled = true;
            }
        }

For your convenience, I've prepared a small sample project which demonstrates how to handle both scenarios.

Please have a look and let me know if this provides the desired behavior or if I'm missing something of importance.

Regards,
Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
PropertyGrid
Asked by
Karl B
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Karl B
Top achievements
Rank 1
Share this question
or