Example T555679
Visible to All Users

Pivot Grid for WinForms - How to Implement Custom Summary Values for Total, Grand Total, and Data Cells

This example demonstrates how to determine the value type when you calculate custom summary values.

Follow the steps below to create a custom summary:

  1. Create an ExpressionDataBinding object.
  2. Pass the following expression in its constructor as a parameter:
    Code
    Iif(IsTotal([fieldCompanyName]), 'Grand Total', IsTotal([fieldYear]), 'Grand Total', IsTotal([fieldProductName]), 'Total', IsTotal([fieldQuarter]), 'Total', Sum([ProductAmount]))
  3. Assign the ExpressionDataBinding instance to the fieldProductAmount field's DataBinding property.

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

WinPivotCustomSummaryCellType/Form1.cs
C#
using System.Windows.Forms; using DevExpress.XtraPivotGrid; namespace WinPivotCustomSummaryCellType { public partial class Form1 : Form { public Form1() { InitializeComponent(); // This line of code is generated by Data Source Configuration Wizard customerReportsTableAdapter1.Fill(nwindDataSet1.CustomerReports); ExpressionDataBinding expression = new ExpressionDataBinding(); expression.Expression = "Iif(IsTotal([fieldCompanyName]), 'Grand Total', IsTotal([fieldYear]), 'Grand Total', IsTotal([fieldProductName]), 'Total', IsTotal([fieldQuarter]), 'Total', Sum([ProductAmount]))"; fieldProductAmount.DataBinding = expression; } } }
VBWinPivotCustomSummaryCellType/Form1.vb
Visual Basic
Imports DevExpress.XtraPivotGrid Imports DevExpress.Data.PivotGrid Public Class Form1 Sub New() InitializeComponent() ' This line of code is generated by Data Source Configuration Wizard CustomerReportsTableAdapter1.Fill(NwindDataSet1.CustomerReports) Dim expression As New ExpressionDataBinding() expression.Expression = "Iif(IsTotal([fieldCompanyName]), 'Grand Total', IsTotal([fieldYear]), 'Grand Total', IsTotal([fieldProductName]), 'Total', IsTotal([fieldQuarter]), 'Total', Sum([ProductAmount]))" fieldProductAmount1.DataBinding = expression End Sub End Class

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.