New to Telerik UI for WinForms? Download free 30-day trial

Creating Hierarchical Grids

RadGridView has the ability to represent hierarchical master-detail data. Its hierarchical schema set up either at design-time or at runtime using the control API. You can also set the AutoGenerateHierarchy property to True and bind to a System.Data.DataSet type data source to have RadGridView automatically build a hierarchical schema.

Create hierarchical grid

this.ordersTableAdapter.Fill(this.nwindDataSet.Orders);
this.order_DetailsTableAdapter.Fill(this.nwindDataSet.Order_Details);
this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
radGridView1.AutoGenerateHierarchy = true;

Me.OrdersTableAdapter.Fill(Me.NwindDataSet.Orders)
Me.Order_DetailsTableAdapter.Fill(Me.NwindDataSet.Order_Details)
Me.CustomersTableAdapter.Fill(Me.NwindDataSet.Customers)
RadGridView1.AutoGenerateHierarchy = True

The general steps to setting up hierarchical data manually are:

  1. Configure the data source components for each table to be displayed.

  2. Using GridViewTemplate.ChildGridViewTemplates collection, create a hierarchy of templates, one for every level of master-detail relations. Each template should be bound to its own data source.

  3. Populate the Relations collection with GridViewRelation objects. These objects define the relations between views in the hierarchy. The ParentTemplate and ChildTemplate properties of GridViewRelation object are set to the existing templates. ParentColumnNames and ChildColumnNames collections are filled with the names of the fields of the corresponding data sources. See the topic Tutorial: Binding to Hierarchical Data for step by step instructions.

See Also

In this article