Back to Devexpress

Total Summaries

windowsforms-5612-controls-and-libraries-tree-list-feature-center-summaries-total-summaries.md

latest2.6 KB
Original Source

Total Summaries

  • Sep 03, 2021
  • 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.

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.

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

  3. Make the summary footer visible.

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.

csharp
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;
vb
Imports DevExpress.XtraTreeList
Imports DevExpress.XtraTreeList.Columns
' ...
TreeList1.OptionsView.ShowSummaryFooter = True
Dim Column As TreeListColumn = TreeList1.Columns("Budget")
Column.AllNodesSummary = True
Column.SummaryFooterStrFormat = "Total: {0:c0}"
Column.SummaryFooter = SummaryItemType.Sum