Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 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

    DifferenceBinding Class

    Defines the difference calculation between values across a window.

    Namespace: DevExpress.XtraPivotGrid

    Assembly: DevExpress.XtraPivotGrid.v25.1.dll

    NuGet Package: DevExpress.Win.PivotGrid

    #Declaration

    public class DifferenceBinding :
        DifferenceBindingBase

    #Remarks

    To bind a PivotGrid field to the result of the difference window calculations in Optimized mode, do the following:

    1. Create an instance of the DifferenceBinding class.
    2. Set the Source property to the DataBindingBase descendant instance.
    3. Specify the window frame and calculation settings.
    4. Assign the DifferenceBinding instance to the PivotGridField.DataBinding property.

    #Example

    The following code snippet illustrates the use of the Data Binding API to calculate a difference between the preceding and current value in the column:

    Run Demo: Optimized Mode - Field Calculation Bindings

    public static void PivotCalculations(PivotGridControl pivotGridControl) {                        
        DataSourceColumnBinding productAmountBinding = new DataSourceColumnBinding("ExtendedPrice");
        //Calculate a difference between the preceding and current value in the column.
        pivotGridControl.Fields["fDifference"].DataBinding = new DifferenceBinding(
            productAmountBinding, CalculationPartitioningCriteria.ColumnValue, DifferenceTarget.Previous, DifferenceType.Absolute);
    }
    
    See Also