How to Set Focus to Child Add New Row

4 posts, 0 answers
  1. Anumeha
    Anumeha avatar
    36 posts
    Member since:
    Aug 2010

    Posted 18 Feb 2011 Link to this post

    Is there a way to programmatically set the focus to the first cell in a child add new row? 
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 24 Feb 2011 Link to this post

    Hi Anumeha,

    You can use following sample code snippet for your scenario:

    private void radButton1_Click(object sender, EventArgs e)
    {
        if (this.radGridView1.ChildRows.Count > 0)
        {
            this.radGridView1.ChildRows[0].IsExpanded = true;
            GridViewHierarchyRowInfo row = this.radGridView1.ChildRows[0] as GridViewHierarchyRowInfo;
            if (row != null)
            {
                this.radGridView1.CurrentRow = row.ActiveView.TableAddNewRow;
                this.radGridView1.CurrentColumn = row.ActiveView.ViewTemplate.Columns[0];
            }
        }
    }

    Greetings,
    Julian Benkov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. Ovais
    Ovais avatar
    1 posts
    Member since:
    Oct 2011

    Posted 04 Oct 2011 Link to this post

    Hello Julian,
        I have a hierarchical grid, the parent row of which is user input and I fill the child rows dynamically through a datasource. The problem is on UserAddedRow event I am unable to focus the child row's first column. I have used the code snippet you provided but it doesn't seem to work. Here is the code which I am using :
    foreach (GridViewColumn column in gvStockDetail.Relations[0].ChildTemplate.Columns)
    {
        if (column.IsVisible && !column.ReadOnly)
        {
            gvStockDetail.Relations[0].ChildTemplate.CurrentColumn = column;
            break;
        }
    }
  4. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 06 Oct 2011 Link to this post

    Hello Ovais,

    For this behavior you can use the CurrentColumn and the CurrentRow properties of RadGridView control.

    foreach (GridViewColumn column in gvStockDetail.Relations[0].ChildTemplate.Columns)
    {
        if (column.IsVisible && !column.ReadOnly)
        {
            gvStockDetail.CurrentColumn = column;
            break;
        }
    }

    I hope this helps. Let me know if you need further assistance.

    Kind regards,
    Julian Benkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top