Back to Devexpress

How to: Calculate the sum against all nodes

windowsforms-5614-controls-and-libraries-tree-list-examples-summaries-how-to-calculate-the-sum-against-all-nodes.md

latest1.6 KB
Original Source

How to: Calculate the sum against all nodes

  • Nov 13, 2018

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