CustomGroupDisplayTextEventArgs.DisplayText Property

Gets or sets the text displayed within the processed group row.

Namespace: DevExpress.Xpf.Grid

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

Declaration

public string DisplayText { get; set; }

Property Value

Type Description
String

A String value that specifies the text displayed within the processed group row.

Example

The following example shows how to apply custom rules to group rows. When you group data by the Unit Price column, rows in this column that have values between 0 and 10 are combined into a single group. Rows whose values fall between 10 and 20 are combined into another group, and so forth.

DevExpress WPF | Grid Control - Custom Group Rules

View Example: How to Apply Custom Rules to Group Rows

<dxg:GridControl x:Name="grid" 
                 CustomColumnGroup="OnCustomColumnGroup" 
                 CustomGroupDisplayText="OnCustomGroupDisplayText">
    <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" ShowGroupedColumns="True"/>
    </dxg:GridControl.View>
</dxg:GridControl>
void OnCustomColumnGroup(object sender, CustomColumnSortEventArgs e) {
    if(e.Column.FieldName != "UnitPrice")
        return;
    double x = Math.Floor(Convert.ToDouble(e.Value1) / 10);
    double y = Math.Floor(Convert.ToDouble(e.Value2) / 10);
    e.Result = x > 9 && y > 9 ? 0 : x.CompareTo(y);
    e.Handled = true;
}

void OnCustomGroupDisplayText(object sender, CustomGroupDisplayTextEventArgs e) {
    if(e.Column.FieldName != "UnitPrice")
        return;
    string interval = IntervalByValue(e.Value);
    e.DisplayText = interval;
}

// Gets the interval which contains the specified value.
private string IntervalByValue(object val) {
    double d = Math.Floor(Convert.ToDouble(val) / 10);
    string ret = string.Format("{0:c} - {1:c} ", d * 10, (d + 1) * 10);
    if(d > 9)
        ret = string.Format(">= {0:c} ", 100);
    return ret;
}
See Also