Skip to main content
A newer version of this page is available. .

DataGridView.GroupCollapsing Event

Occurs before a group of rows is collapsed.

Namespace: DevExpress.Maui.DataGrid

Assembly: DevExpress.Maui.DataGrid.dll

NuGet Package: DevExpress.Maui.DataGrid

Declaration

public event EventHandler<CancelRowEventArgs> GroupCollapsing

Event Data

The GroupCollapsing event's data class is CancelRowEventArgs. The following properties provide information specific to this event:

Property Description
Cancel Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
RowHandle Returns the handle of the processed row.

Remarks

The GroupCollapsing event is raised before a group of data rows is collapsed from UI or code (CollapseGroupRow. You can handle this event and set its parameter’s Cancel property to true to prevent a group from being collapsed.

When you call the CollapseAllGroups method, the GroupCollapsing event is raised for each group.

After the group row has been collapsed, the GroupCollapsed event is raised.

Example

The example below shows how to prevent the “Today” group in the grid from being collapsed. To obtain the group value, the DataGridView.GetGroupValue method is used.

<dxg:DataGridView x:Name="grid" ItemsSource="{Binding Orders}" 
                  GroupCollapsing="grid_GroupCollapsing">
    <dxg:DataGridView.Columns>
        <!--...-->
        <dxg:DateColumn x:Name="DateColumn"
                        FieldName="Date"
                        DisplayFormat="d"
                        GroupInterval="DateRange" 
                        IsGrouped="True"/>
        <!--...-->
    </dxg:DataGridView.Columns>
</dxg:DataGridView>
private void grid_GroupCollapsing(object sender, RowAllowEventArgs e) { 
    string groupValue = (string)grid.GetGroupValue(e.RowHandle);
    if (groupValue == "Today") e.Allow = false;   
}
See Also