FlexGrid for WPF | ComponentOne
C1.WPF.FlexGrid.4.6.2 Assembly / C1.WPF.FlexGrid Namespace / C1FlexGrid Class / CollapseGroupsToLevel Method
Grouping level to show.
Example

In This Topic
    CollapseGroupsToLevel Method
    In This Topic
    Collapses all the group rows to a given level.
    Syntax
    'Declaration
     
    Public Sub CollapseGroupsToLevel( _
       ByVal level As Integer _
    ) 
    public void CollapseGroupsToLevel( 
       int level
    )

    Parameters

    level
    Grouping level to show.
    Remarks

    When the grid is bound to a grouped data source, it automatically adds group rows above each group. Individual group rows can be collapsed or expanded using the GroupRow.IsCollapsed property.

    This method allows the caller to expand or collapse the entire outline to a given level.

    For example, if the grid is bound to a data source with three group descriptors, then CollapseGroupsToLevel(0) would collapse all top-level group rows, showing only the first level of the grouping outline. CollapseGroupsToLevel(2) would show all the group rows, and no data rows. CollapseGroupsToLevel(3) would show all rows (groups and detail).

    The code below creates data source with three levels of grouping, then shows the first two levels of the grouping outline: // create grouped data source var view = new PagedCollectionView(dataList); var gd = view.GroupDescriptions; gd.Add(new PropertyGroupDescription("Country")); gd.Add(new PropertyGroupDescription("City")); gd.Add(new PropertyGroupDescription("Customer")); // assign data source to grid _flex.ItemsSource = view; // collapse grouping outline to level 1 // (show country and city groups, hide customer groups and all detail rows) _flex.CollapseGroupsToLevel(1); // expand grouping outline show all detail _flex.CollapseGroupsToLevel(gd.Count); // collapse grouping outline to show all group rows and no detail _flex.CollapseGroupsToLevel(gd.Count - 1);
    Example
    The code below creates data source with three levels of grouping, then shows the first two levels of the grouping outline:
    // create grouped data source
    var view = new PagedCollectionView(dataList);
    var gd = view.GroupDescriptions;
    gd.Add(new PropertyGroupDescription("Country"));
    gd.Add(new PropertyGroupDescription("City"));
    gd.Add(new PropertyGroupDescription("Customer"));
                
    // assign data source to grid
    _flex.ItemsSource = view;
                
    // collapse grouping outline to level 1
    // (show country and city groups, hide customer groups and all detail rows)
    _flex.CollapseGroupsToLevel(1);
                
    // expand grouping outline show all detail
    _flex.CollapseGroupsToLevel(gd.Count);
                
    // collapse grouping outline to show all group rows and no detail
    _flex.CollapseGroupsToLevel(gd.Count - 1);
    See Also