# 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

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

```VB.NET
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](https://www.telerik.com/products/winforms/documentation/controls/gridview/hierarchical-grid/binding-to-hierarchical-data) for step by step instructions.

## See Also

* [Binding the Grid](https://www.telerik.com/products/winforms/documentation/controls/gridview/fundamentals/binding-the-grid)

* [Columns](https://www.telerik.com/products/winforms/documentation/controls/gridview/fundamentals/columns)

* [Editing](https://www.telerik.com/products/winforms/documentation/controls/gridview/fundamentals/editing)

* [Element Hierarchy](https://www.telerik.com/products/winforms/documentation/controls/gridview/fundamentals/element-hierarchy)

* [Key Features](https://www.telerik.com/products/winforms/documentation/controls/gridview/fundamentals/key-features)

* [Keyboard Support](https://www.telerik.com/products/winforms/documentation/controls/gridview/fundamentals/keyboard-support)

* [Logical vs. Visual Grid Structure](https://www.telerik.com/products/winforms/documentation/controls/gridview/fundamentals/logical-vs.-visual-grid-structure)

* [Overview of RadGridView Structure](https://www.telerik.com/products/winforms/documentation/controls/gridview/fundamentals/overview-of-radgridview-structure)
