Skip to main content
A newer version of this page is available. .

GridColumn.DisplayFormat Property

Provides access to the object specifying the formatting applied to column values.

Namespace: DevExpress.XtraGrid.Columns

Assembly: DevExpress.XtraGrid.v19.2.dll

Declaration

[DXCategory("Format")]
[XtraSerializableProperty(XtraSerializationVisibility.Content)]
public FormatInfo DisplayFormat { get; }

Property Value

Type Description
FormatInfo

A FormatInfo object that specifies format settings for column values.

Remarks

Settings provided by this property allow you to format column values in display mode and when the grid is exported/printed.

You can implement cell formatting by using the DisplayFormat.Format (FormatInfo.Format) property. String formatting implemented in this way is not supported when a grid’s edit values (not display text) are exported to XLS format. To specify the cell export mode, use the RepositoryItem.ExportMode and/or XlExportOptionsBase.TextExportMode properties.

Note

Changing the DisplayFormat.FormatType property automatically resets the DisplayFormat.FormatString property. Thus, it is recommended to set DisplayFormat.FormatType prior to DisplayFormat.FormatString.

Please refer to the Formatting Cell Values topic for additional information.

Example

The following code shows how to format column values using the standard format strings. Values in the colPayment column are formatted as a currency amount, values in the colPurchaseDate column are formatted using the Long Date Pattern.

The result is shown below:

Format - StandardStrings

using DevExpress.Utils;
// ...
colPayment.DisplayFormat.FormatType = FormatType.Numeric;
colPayment.DisplayFormat.FormatString = "c2";
colPurchaseDate.DisplayFormat.FormatType = FormatType.DateTime;
colPurchaseDate.DisplayFormat.FormatString = "D";
See Also