How To Generate The Two Level Detailsviewdatagrid With Datatable Collection In Winforms Datagrid?

Sample date Updated on Dec 22, 2025
dadtatable detailsview detailsviewdatagrid twolevel windows-forms winforms winforms-datagrid

This sample illustrates how to generate the two level DetailsViewDataGrid with DataTable collection in WinForms DataGrid (SfDataGrid).

By default, the DetailsView will be added for single relation when the AutoGenerateRelations is enabled. To add multiple related tables in DataGrid, AutoGenerateRelations for each grid can be enabled through SfDataGrid.AutoGeneratingRelations event.

//Event subscription
this.sfDataGrid1.AutoGeneratingRelations += new Syncfusion.WinForms.DataGrid.Events.AutoGeneratingRelationsEventHandler(SfDataGrid1_AutoGeneratingRelations);

//Event customization
private void SfDataGrid1_AutoGeneratingRelations(object sender, Syncfusion.WinForms.DataGrid.Events.AutoGeneratingRelationsEventArgs e)
{
    //To enable AutoGenerateColumns for child grid.
    e.GridViewDefinition.DataGrid.AutoGenerateRelations = true;
}

DataGrid with two level of DetailsViewDataGrid bound with DataTable

Up arrow