Focus Navigation between two grids

1 Answer 23 Views
Top achievements
Rank 1
Bidder asked on 20 Nov 2021, 02:18 PM


I have two gridviews in a form: Master and Detail. I am trying to set the focus on Detail Grid when the Master grid UserAddedRow Event occurs. I tried with Telerik grids, but, it doesn't work. The focus always stays in the Master grid.

In other question, you answer me with the below code sample, but, this sample shows the Detail grid inside the Master grid. My customer wants to do what I am showing in the PNG attachment, in order to make the fingering fast.

The sample in PNG was developed in native VS DataGridView.


Code sample:

  DataTable masterTable = new DataTable();
        DataTable childTable = new DataTable();

        public RadForm1()

            masterTable.Columns.Add("Id", typeof(int));
            masterTable.Columns.Add("Name", typeof(string));
            for (int i = 0; i < 3; i++)
                masterTable.Rows.Add(i, "Row" + i);
            childTable.Columns.Add("Id", typeof(int));
            childTable.Columns.Add("ParentId", typeof(int));
            childTable.Columns.Add("Title", typeof(string));
            childTable.Columns.Add("Date", typeof(DateTime));
            Random rand = new Random();
            for (int i = 0; i < 20; i++)
                childTable.Rows.Add(i, rand.Next(0, 3), "Child" + i, DateTime.Now.AddDays(i));

            radGridView1.DataSource = masterTable;
            radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

            GridViewTemplate template = new GridViewTemplate();
            template.DataSource = childTable;
            template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

            GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate);
            relation.ChildTemplate = template;
            relation.RelationName = "MasterChild";


        private void radGridView1_UserAddedRow(object sender, GridViewRowEventArgs e)
            e.Row.IsExpanded = true;
            this.radGridView1.CurrentRow = ((GridViewHierarchyRowInfo)e.Row).Views[0].TableAddNewRow;
            this.radGridView1.CurrentColumn = this.radGridView1.MasterTemplate.Templates[0].Columns[0];

1 Answer, 1 is accepted

Sort by
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 Nov 2021, 11:42 AM

If you need to have two separate grids for the master and child records, I would recommend you to have a look at the following KB article which is quite useful on this topic: 

The following code snippet demonstrates how to focus the second grid and activate the editor for it once the user added a new row in the first grid.
        private void RadGridView1_UserAddedRow(object sender, GridViewRowEventArgs e)
            this.ActiveControl = this.radGridView2;
            this.radGridView2.CurrentRow = this.radGridView2.MasterView.TableAddNewRow;

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at

Asked by
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question