Standard Formatting

  • 2 minutes to read

DevExpress controls use a standard formatting mechanism to format values as described in Microsoft documentation. The current document describes specific API related to formatting values displayed in the PivotGridControl.

The PivotGridControl formats displayed values using the application's specified culture by default. For instance, the images below demonstrate the same Pivot Grid whose date-time and summary values are formatted as "en-US" or "de-DE".

You can change default formatting settings for data cells, field values, totals and grand totals using the following properties:

Member Description
PivotGridFieldBase.CellFormat Provides access to the format settings applied to cells.
PivotGridFieldBase.GrandTotalCellFormat Provides access to the format settings applied to grand total values.
PivotGridFieldBase.TotalCellFormat Provides access to the format settings applied to total cells.
PivotGridFieldBase.TotalValueFormat Provides access to the format settings applied to the total header.
PivotGridFieldBase.ValueFormat Provides access to the format settings applied to field values.

Example: How to Format Cell Values

The following example shows how to format Order Date field values and summaries corresponding to the Extended Price field. Order Date field values are formatted using a long date pattern while Extended Price summaries are formatted as integer currency values.

The result of the code is shown below:

WpfPivot_Formatting_Example

<dxpg:PivotGridControl.Fields>
    <dxpg:PivotGridField Area="DataArea" FieldName="Extended_Price" CellFormat="c0"/>
    <dxpg:PivotGridField Area="RowArea" FieldName="OrderDate" GroupInterval="Date" ValueFormat="D"/>
    <dxpg:PivotGridField Area="ColumnArea" FieldName="Country"/>  
</dxpg:PivotGridControl.Fields>