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

GridControl.CustomSummary Event

Enables you to calculate summary values manually.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v18.2.dll

Declaration

public event CustomSummaryEventHandler CustomSummary

Event Data

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

Property Description
FieldValue Gets the processed field value.
GroupLevel Gets the nested level of the group whose summary value is being calculated.
GroupRowHandle Gets a value identifying the group row whose child data rows are involved in summary calculation.
IsGroupSummary Gets whether a group summary value is being calculated.
IsTotalSummary Gets whether a total summary value is being calculated.
Item Gets a summary item whose value is being calculated.
Row Gets the currently processed row.
RowHandle Gets the handle of the processed row.
SummaryProcess Gets a value indicating calculation stage.
TotalValue Gets or sets the total summary value.
TotalValueReady Gets or sets whether the Calculation stage of the custom summary calculation process should be skipped.

The event data class exposes the following methods:

Method Description
GetGroupSummary(Int32, Object) Returns the value of the specified group summary for the specified group row.
GetValue(String) Returns the value in the specified field

Remarks

Total summaries and group summaries provide five predefined aggregate functions (COUNT, MAX, MIN, SUM and AVG). If you want to calculate summaries using custom rules, handle the CustomSummary event. This event enables you to implement custom aggregate functions or calculate summary values, using a custom algorithm.

If the GridControl.View property is set to TreeListView, the CustomSummary event is not raised. Use the TreeListView.CustomSummary event instead.

Note

The CustomSummary event does not work in Server Mode.

To learn more, see Custom Summary.

Example

The following example demonstrates how to use custom summaries to count the total number of empty cells in the specified grid column.

Note

A complete sample project is available at https://github.com/DevExpress-Examples/how-to-summarize-empty-cells-e948.

<Window x:Class="CustomSummary_EmptyCells.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
    Title="Window1" Height="350" Width="450" >
    <Grid>
        <dxg:GridControl x:Name="grid" CustomSummary="grid_CustomSummary" GroupCount="1">
            <dxg:GridControl.SortInfo>
                <dxg:GridSortInfo FieldName="Text" />
            </dxg:GridControl.SortInfo>
            <dxg:GridControl.Columns>
                <dxg:GridColumn FieldName="Text" />
                <dxg:GridColumn FieldName="Number" />
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TableView x:Name="view" AutoWidth="True" 
                                    NavigationStyle="Cell" ShowTotalSummary="True"/>
            </dxg:GridControl.View>
            <dxg:GridControl.TotalSummary>
                <dxg:GridSummaryItem FieldName="Number" SummaryType="Custom" 
                                    DisplayFormat="Total empty cells count: {0}"/>
            </dxg:GridControl.TotalSummary>
            <dxg:GridControl.GroupSummary>
                <dxg:GridSummaryItem FieldName="Number" SummaryType="Custom" 
                                    DisplayFormat="Group empty cells count: {0}"/>
            </dxg:GridControl.GroupSummary>
        </dxg:GridControl>
    </Grid>
</Window>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomSummary 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