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

GridControl.CustomColumnGroup Event

Provides the ability to group data using custom rules.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v19.1.dll

Declaration

public event CustomColumnSortEventHandler CustomColumnGroup

Event Data

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

Property Description
Column Gets the column whose values are being compared.
Handled Gets or sets whether a comparison operation is handled and no default processing is required.
ListSourceRowIndex1 Gets the index of the first of the two rows being compared in the data source.
ListSourceRowIndex2 Gets the index of the second of the two rows being compared in the data source.
Result Gets or sets the result of a custom comparison.
SortOrder Gets the sort order applied to the column.
Source Gets the grid control that raised the event.
Value1 Gets the first value being compared.
Value2 Gets the second value being compared.

Remarks

If the built-in grouping modes don’t suit your requirements, you can implement custom logic. To do this, set the ColumnBase.SortMode property to ‘Custom’, and handle the CustomColumnGroup event. To change the text displayed within group rows by default, handle the GridControl.CustomGroupDisplayText event.

Note

The CustomColumnGroup event does not work in Server Mode.

Example

This example shows how to group rows using custom rules. When grouping by the 'Unit Price' column, the rows in this column that have values between 0 and 10 should be combined into a single group. Rows whose values fall between 10 and 20 should be combined into another group, etc.

<Window x:Class="DXGrid_CustomGrouping.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
        Title="Window1" Height="300" Width="509">
    <Grid>
        <dxg:GridControl x:Name="grid" 
                         CustomColumnGroup="grid_CustomColumnGroup" 
                         CustomGroupDisplayText="grid_CustomGroupDisplayText"
                         ItemsSource="{Binding ListPerson}"
                         >
            <dxg:GridControl.Columns>
                <dxg:GridColumn FieldName="FirstName" />
                <dxg:GridColumn FieldName="LastName" />
                <dxg:GridColumn FieldName="UnitPrice" SortMode="Custom" GroupIndex="0">
                    <dxg:GridColumn.EditSettings>
                        <dxe:SpinEditSettings DisplayFormat="c2" />
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TableView AutoWidth="True" />
            </dxg:GridControl.View>
        </dxg:GridControl>
    </Grid>
</Window>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomColumnGroup event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also