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

How to Set Focus to Child Add New Row

3 Answers 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anumeha
Top achievements
Rank 1
Anumeha asked on 18 Feb 2011, 07:48 PM
Is there a way to programmatically set the focus to the first cell in a child add new row? 

3 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 24 Feb 2011, 01:34 PM
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!
0
Ovais
Top achievements
Rank 1
answered on 04 Oct 2011, 07:03 AM
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;
    }
}
0
Julian Benkov
Telerik team
answered on 06 Oct 2011, 03:57 PM
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 >>

Tags
GridView
Asked by
Anumeha
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Ovais
Top achievements
Rank 1
Share this question
or