We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the grand total header of row and column in WinForms PivotGrid control?

Platform: WinForms |
Control: PivotGridControl

Customizing grand total header of rows

You can customize the grand total header of a row by using the FormattedText property of the row’s grand total cell.

Refer to the following code sample to customize the grand total header of a row as the “Total” instead of the “Grand Total”.

C#

for (int row = this.pivotGridControl1.PivotEngine.RowCount - 1; row >= 0; row--)
{
     PivotCellInfo cellInfo = this.pivotGridControl1.PivotEngine[row, 0];
     if (cellInfo != null && cellInfo.FormattedText != null && cellInfo.CellType == (PivotCellType.RowHeaderCell | PivotCellType.GrandTotalCell))
     {
          cellInfo.FormattedText = "Total";
          break;
     }
}

VB

For row As Integer = Me.pivotGridControl1.PivotEngine.RowCount - 1 To 0 Step -1
    Dim cellInfo As PivotCellInfo = Me.pivotGridControl1.PivotEngine(row, 0)
    If cellInfo IsNot Nothing AndAlso cellInfo.FormattedText IsNot Nothing AndAlso cellInfo.CellType Is (PivotCellType.RowHeaderCell Or PivotCellType.GrandTotalCell) Then
          cellInfo.FormattedText = "Total"
          Exit For
    End If
Next row

 

Pivot grid rendered with customized row grand total header

Pivot grid rendered with customized row grand total header

Customizing grand total header of columns

You can customize the grand total header of a column by using the FormattedText property of the column’s grand total cell.

Refer to the following code sample to customize the grand total header of column as the “Total” instead of “Grand Total”.

C#

for (int column = this.pivotGridControl1.PivotEngine.ColumnCount - 1; column >= 0; column--)
{
     PivotCellInfo cellInfo = this.pivotGridControl1.PivotEngine[0, column];
     if (cellInfo != null && cellInfo.FormattedText != null && cellInfo.CellType == (PivotCellType.ColumnHeaderCell | PivotCellType.GrandTotalCell))
     {
         cellInfo.FormattedText = "Total";
         break;
     }
}

VB

For column As Integer = Me.pivotGridControl1.PivotEngine.ColumnCount - 1 To 0 Step -1
     Dim cellInfo As PivotCellInfo = Me.pivotGridControl1.PivotEngine(0, column)
     If cellInfo IsNot Nothing AndAlso cellInfo.FormattedText IsNot Nothing AndAlso cellInfo.CellType Is (PivotCellType.ColumnHeaderCell Or PivotCellType.GrandTotalCell) Then
        cellInfo.FormattedText = "Total"
        Exit For
     End If
Next column

 

Pivot grid rendered with customized column grand total header

Pivot grid rendered with customized column grand total header

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile