Description:
How can I Auto-Expand all Sub-Detail Views when Expanding my Root Master Rows
Answer:
The best way to implement such a capability is to write a handler for the MasterRowExpanded event of your root Grid view. Simply retrieve the Detail view object of the current Master row, traverse all its rows and call the SetMasterRowExpanded method to accomplish the auto-expand.
Here is some sample code:
C#using DevExpress.XtraGrid.Views.Grid;
...
private void gridView_MasterRowExpanded(object sender, DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs e) {
GridView masterView = sender as GridView;
GridView detailView = masterView.GetDetailView(e.RowHandle) as GridView;
masterView.BeginUpdate();
for(int i = 0; i < detailView.DataRowCount; i++)
detailView.SetMasterRowExpanded(i, true);
masterView.EndUpdate();
Visual BasicImports DevExpress.XtraGrid.Views.Grid
...
Private Sub GridView1_MasterRowExpanded(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs) Handles GridView1.MasterRowExpanded
Dim masterView As GridView = CType(sender, GridView)
Dim detailView As GridView = CType(masterView.GetDetailView(e.RowHandle), GridView)
masterView.BeginUpdate()
Dim i As Integer
For i = 0 To detailView.DataRowCount - 1
detailView.SetMasterRowExpanded(i, True)
Next i
masterView.EndUpdate()
End Sub