Skip to main content

Total Summaries

  • 2 minutes to read

Total summaries are calculated against all nodes or only root nodes. This topic describes how to implement total summaries in a Tree List control.

image

Online Video

WinForms Tree List - How to Create and Display a Summary in Code.

Total Summaries

Basic steps of implementing a total summary are:

  1. Specify the type of total summary for a column.

    Set the TreeListColumn.SummaryFooter property to the desired type of aggregate function (a value other than SummaryItemType.None);

  2. Specify whether the total summary must be calculated only for root nodes or against all nodes.

    Use the TreeListColumn.AllNodesSummary property to enable summary calculation against all nodes. By default, it’s set to false.

  3. Make the summary footer visible.

    Total summaries are displayed in the summary footer. So, enable the TreeListOptionsView.ShowSummaryFooter option to see total summary values.

In addition, you can specify the format for total summary values. To do this, use the TreeListColumn.SummaryFooterStrFormat property. See Formatting Summary Values to learn more.

Example

The following example demonstrates how to calculate the Budget column’s sum. The TreeListColumn.SummaryFooter and TreeListColumn.SummaryFooterStrFormat properties specify the function type and summary value formatting.

The TreeListColumn.AllNodesSummary property is set to true to calculate the summary across all nodes within the control. The TreeListOptionsView.ShowSummaryFooter option is enabled to display the summary footer.

image

using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Columns;
// ...
treeList1.OptionsView.ShowSummaryFooter = true;
TreeListColumn column = treeList1.Columns["Budget"];
column.AllNodesSummary = true;
column.SummaryFooterStrFormat = "Total: {0:c0}";
column.SummaryFooter = SummaryItemType.Sum;