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

How to change Grid focus to adding new row First cell After add New Row

5 Answers 533 Views
GridView
This is a migrated thread and some comments may be shown as answers.
sajeev ks
Top achievements
Rank 1
sajeev ks asked on 04 Oct 2012, 09:56 AM
Hi
Please give me Correct Answer

How to change Grid focus to adding new row  First cell After add New Row

Thanks

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 08 Oct 2012, 01:57 PM
Hello Sajeev,

Thank you for writing.

Here is how to set the focus to the first cell in the new row in RadGridView, when another row is added:
void radGridView1_UserAddedRow(object sender, GridViewRowEventArgs e)
       {
           radGridView1.MasterView.TableAddNewRow.Cells[0].BeginEdit();
       }

I hope this helps.
 
Greetings,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
sajeev ks
Top achievements
Rank 1
answered on 17 Oct 2012, 08:58 AM
Itz Not Working........

AM Using Telerik RadControls 2011 Q1

Only working first time....
Next item added But Not Set focs cell(0).

plz give me  correct answer...

any way Thanks for responding................
0
sajeev ks
Top achievements
Rank 1
answered on 17 Oct 2012, 09:52 AM
IF ADDNEWROW POSITION=BOTTOM This code is working
   grd.MasterView.TableAddNewRow.Cells(1).BeginEdit()

But POSTION TOP Not working
0
Accepted
Stefan
Telerik team
answered on 22 Oct 2012, 10:38 AM
Hello Sajeev,

In this case, please consider replacing the default grid behavior with the following one:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        radGridView1.Columns.Add("ada");
        for (int i = 0; i < 10; i++)
        {
            radGridView1.Rows.Add(10, "test", "test");
        }
 
           radGridView1.GridBehavior = new MyBehavior();
    }
}
 
class MyBehavior : BaseGridBehavior
{
    public override bool ProcessKey(KeyEventArgs keys)
    {
        if (this.GridControl.CurrentRow is GridViewNewRowInfo)
        {
            if (keys.KeyData == Keys.Enter || keys.KeyData == Keys.Down || keys.KeyData == Keys.Up)
            {
                this.GridControl.EndEdit();
                this.GridControl.GridNavigator.SelectPreviousRow(1);
                this.GridControl.GridNavigator.SelectFirstColumn();
                this.GridControl.BeginEdit();
            }
            else if (this.GridControl.GridNavigator.IsLastColumn(this.GridControl.CurrentColumn) && keys.KeyData == Keys.Tab)
            {
                this.GridControl.EndEdit();
                this.GridControl.GridNavigator.SelectPreviousRow(1);
                this.GridControl.GridNavigator.SelectFirstColumn();
                this.GridControl.BeginEdit();
            }
            else if (keys.KeyData == Keys.Tab)
            {
                this.GridControl.GridNavigator.SelectNextColumn();
            }
            return true;
        }
        else
        {
            return base.ProcessKey(keys);
        }
    }
}

Let me know how this works for you.
 
Greetings,
Stefan
the Telerik team
You’ve been asking for it and now it’s time for us to deliver. RadControls for WinForms Q3 2012 release is just around the corner. Sign up for a free webinar to see first all the latest enhancements.
0
sajeev ks
Top achievements
Rank 1
answered on 03 Dec 2012, 07:31 AM
THANK YOU VERY MUCH...........
ITZ WORING..............

Thanks Dude.......!
Tags
GridView
Asked by
sajeev ks
Top achievements
Rank 1
Answers by
Stefan
Telerik team
sajeev ks
Top achievements
Rank 1
Share this question
or