Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Implement a custom summary

The following example calculates the number of records for which the “Budget” column’s value exceeds 500,000. The setCustomSummary method sets the custom summary type for the Budget column. The TreeList.GetCustomSummaryValue event handler implements the calculation logic.

The image below shows the result.

CustomSummary

private void setCustomSummary() {
   treeList1.OptionsView.ShowRowFooterSummary = true;
   treeList1.Columns["Budget"].RowFooterSummary = SummaryItemType.Custom;
   treeList1.Columns["Budget"].RowFooterSummaryStrFormat = "{0} nodes exceed limit";
}

private void treeList1_GetCustomSummaryValue(object sender, DevExpress.XtraTreeList.GetCustomSummaryValueEventArgs e) {
   if(e.Column.FieldName == "Budget") {
      IEnumerator en = e.Nodes.GetEnumerator();
      int exceedingLimitNodes = 0;
      while(en.MoveNext()) {
         TreeListNode node = (TreeListNode)en.Current;
         decimal budget = (decimal)node.GetValue(e.Column);
         if(budget > 500000) {
            exceedingLimitNodes ++;
            //...
         }
      }
      e.CustomValue = exceedingLimitNodes;
   }
}