How to collapse the details view datagrid inside the Groups in DataGrid?
By default, DetailsViewDataGrid expanded state is maintain when group of DataGrid is collapsed. If we need to collapse the DetailsViewDataGrid when group of DataGrid is collapsed, this can be achieved by disabling the IsExpanded of DetailsViewDataGrid in SfDataGrid.GroupExpanding event.
this.sfDataGrid1.GroupExpanding += SfDataGrid1_GroupExpanding; private void SfDataGrid1_GroupExpanding(object sender, Syncfusion.WinForms.DataGrid.Events.GroupChangingEventArgs e) { CollapseAllNestedGrids(e.Group); } void CollapseAllNestedGrids(Group group) { if (group != null && group.Records != null) { foreach (var item in group.Records) { if (item.IsGroups == false) item.IsExpanded = false; } } if (group.Groups != null) { foreach (var item in group.Groups) CollapseAllNestedGrids(item); } }
Sample Link: WinForms Sample
Conclusion
I hope you enjoyed learning about how to collapse the details view datagrid inside the Groups in DataGrid.
You can refer to our WinForms DataGrid feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms DataGrid documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!