Back to Devexpress

How to: Customize the Grand Total Text in the FieldValueDisplayText Event

wpf-120119-controls-and-libraries-pivot-grid-examples-miscellaneous-how-to-customize-the-grand-total-text-using-the-fieldvaluedisplaytext-event.md

latest1.7 KB
Original Source

How to: Customize the Grand Total Text in the FieldValueDisplayText Event

  • Jul 24, 2019

The PivotGridControl.FieldValueDisplayText event allows you to customize field value texts for grand totals.

To do this, check the field value type using the PivotFieldValueEventArgs.ValueType event parameter and provide the required display texts using PivotFieldDisplayTextEventArgs.DisplayText.

csharp
private void PivotGridControl_FieldValueDisplayText(object sender, DevExpress.Xpf.PivotGrid.PivotFieldDisplayTextEventArgs e) {
    if (e.ValueType == DevExpress.Xpf.PivotGrid.FieldValueType.GrandTotal) {
        if (e.IsColumn)
            e.DisplayText = "*Custom Column Grand Total*";
        else
            e.DisplayText = "*Custom Row Grand Total*";
    }
}
vb
Private Sub PivotGridControl_FieldValueDisplayText(ByVal sender As Object, ByVal e As DevExpress.Xpf.PivotGrid.PivotFieldDisplayTextEventArgs)
    If e.ValueType = DevExpress.Xpf.PivotGrid.FieldValueType.GrandTotal Then
        If e.IsColumn Then
            e.DisplayText = "*Custom Column Grand Total*"
        Else
            e.DisplayText = "*Custom Row Grand Total*"
        End If
    End If
End Sub