The cell of row of Grid view index go to next cell

2 posts, 0 answers
  1. Ayman
    Ayman avatar
    3 posts
    Member since:
    Jun 2013

    Posted 18 Jun 2013 Link to this post

    hello

    I'm using this code to get the focus on the new row, first cell after inserting a row

    private void myGrid_UserAddingRow(object sender, GridViewRowCancelEventArgs e)
    {  
        myGrid.CurrentRow.Cells[0].BeginEdit();
    }


    but the focus goes to second cell of the new row 

    what is the problem

    thanks
  2. George
    Admin
    George avatar
    500 posts

    Posted 21 Jun 2013 Link to this post

    Hello Ayman,

    I am glad you contacted us.

    To select the last added row and edit it, first you need to subscribe to the UserAddedRow event, which will trigger after the row has already been added to the collection of rows, which on the other hand will allow us to easily access the last element in that collection. Please see the code below:
    private void radGridView1_UserAddedRow(object sender, Telerik.WinControls.UI.GridViewRowEventArgs e)
            {
                int lastRowPosition = this.radGridView1.ChildRows.Count - 1;
                this.radGridView1.Rows[lastRowPosition].Cells[0].BeginEdit();
            }

    I hope this helps.

    Off topic, you have posted the same thread in the ChartView section. Due to duplicity the other thread is deleted.

    Regards,
    George
    Telerik
    RadChart for WinForms is obsolete. Now what?
Back to Top