Completed
Last Updated: 21 Jun 2018 14:11 by ADMIN
ADMIN
Dimitar
Created on: 23 Mar 2018 09:15
Category: GridView
Type: Bug Report
0
FIX. RadGridView - exception when the new row is at the bottom and the tab key is used
To reproduce:
Use the following code
private void RadGridView1_UserAddingRow(object sender, GridViewRowCancelEventArgs e)
{
    radGridView1.MasterView.TableAddNewRow.CancelAddNewRow();
    radGridView1.MasterView.ViewTemplate.DataView.CurrentItem.IsCurrent = false;
}

Place the new row at the bottom. While in edit mode press tab to fill until an exception is thrown.

Workaround:
BaseGridBehavior gridBehavior = radGridView1.GridBehavior as BaseGridBehavior;
gridBehavior.UnregisterBehavior(typeof(GridViewNewRowInfo));
gridBehavior.RegisterBehavior(typeof(GridViewNewRowInfo), new CustomGridRowBehavior());


internal class CustomGridRowBehavior : GridNewRowBehavior
{
    protected override bool ProcessTabKey(KeyEventArgs keys)
    {
        bool newRowIsInEditMode = this.IsInEditMode && this.GridViewElement.CurrentRow is GridViewNewRowInfo;

        if ( newRowIsInEditMode  && this.GridViewElement.Navigator.IsLastEditableColumn(this.GridViewElement.CurrentColumn))              
        {
            this.GridViewElement.Navigator.SelectFirstColumn();

            while (this.GridViewElement.CurrentColumn.ReadOnly && this.GridViewElement.Navigator.SelectNextColumn())
            { }
            return false;
        }
        return base.ProcessTabKey(keys);
    }
}
0 comments