Data Formatting
- 2 minutes to read
PivotGridControl uses a standard formatting mechanism to format displayed values. Refer to Formatting Values for more information on DevExpress WinForms data-aware controls.
The PivotGridControl formats values using the culture specified in the application 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
The following example shows how to format OrderDate field values and summaries corresponding to the Extended Price field. OrderDate field values are formatted using a long date pattern while Extended Price summaries are formatted as integer currency values.
Refer to the Standard Numeric Format Strings topic for detailed information about the standard numeric format specifiers.
The result of the code is shown below:
// Formats the OrderDate field's values using a long date pattern.
fieldOrderDate.ValueFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
fieldOrderDate.ValueFormat.FormatString = "D";
// Formats the ExtendedPrice field's values as integer currency values.
fieldExtendedPrice.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
fieldExtendedPrice.CellFormat.FormatString = "c0";