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

Clicking 'Tab' creates a new row

7 Answers 157 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 20 Nov 2017, 10:39 PM

Description:

• When I click on the 'New row', it creates a blank new row.

• When I tab to a Decimal column and add something there and click tab (Note it isnot the last column), it creates an empty row.

I don't get this if instead of clicking tab, I actually click in the next cell.

7 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 23 Nov 2017, 02:16 PM
Hello John,

This behavior is expected. Basically, when you are in the last cell of the last column and the Tab Key is pressed new row will be added. In this moment the grid is still in edit mode. That is why new row will appear. To workaround this you can create custom KeyboardCommandProvider. This approach is further described in the Keyboard Command Provider help article. In your case, you can try the following code snippet.
public class CustomKeyboardCommandProvider : DefaultKeyboardCommandProvider
{
    private GridViewDataControl parentGrid;
 
    public CustomKeyboardCommandProvider(GridViewDataControl grid)
     : base(grid)
    {
        this.parentGrid = grid;
    }
 
    public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
    {
        List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList();
        if (key == Key.Tab && (parentGrid.CurrentColumn.DisplayIndex == parentGrid.Columns.Count - 1))
        {
            commandsToExecute.Clear();
            parentGrid.Items.CommitNew();
            commandsToExecute.Add(RadGridViewCommands.CommitEdit);
            commandsToExecute.Add(RadGridViewCommands.BeginInsert);
        }
 
        return commandsToExecute;
    }
}

Give it a try and let me know if it works for you.

Regards,
Dinko
Progress Telerik
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.
0
John
Top achievements
Rank 1
answered on 27 Nov 2017, 02:04 PM
Thanks, I'll give it a try this morning
0
John
Top achievements
Rank 1
answered on 27 Nov 2017, 03:46 PM

I made a mistake and asked this question in the wrong forum. I am working in Winforms not WPF. Will this still work?

I cannot find where DefaultKeyboardCommandProvider is referenced?

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Nov 2017, 06:03 AM
Hello, John, 

Thank you for writing back. 

Your question regarding the Telerik UI for WinForms suite has already been answered in the other thread "Clicking tab creates new row" you have opened on the same topic. Please, see our answer there for more information. I have converted it into a support ticket in order to allow attachments. You can find the ticket in your Telerik Account.

We kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.

Thank you for your understanding.

Regards,
Dess
Progress Telerik
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.
0
John
Top achievements
Rank 1
answered on 29 Nov 2017, 01:56 PM
This solution does not work for WinForms.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Nov 2017, 02:09 PM
Hello, John,

Thank you for writing back.

I would like to note that this forum is related to RadGridView for WPF, not WinForms. If you have any questions regarding the WinForms RadGridView, feel free to post your inquiries in the relevant forum: https://www.telerik.com/forums

It seems that you have already opened a thread with the same description with RadGridView for WinForms product. I would kindly ask you to continue the communication related to RadGridView for WinForms there: https://www.telerik.com/forums/clicking-'tab'-creates-a-new-row-194c3f47ec8e

Thank you for your understanding.

Regards,
Dess
Progress Telerik
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.
0
John
Top achievements
Rank 1
answered on 29 Nov 2017, 02:35 PM
Yes, I made a mistake as I already said. Please leave the post open in the WinForms forum. You can close this one
Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
John
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or