GridColumn.DisplayFormat Property
Provides access to the object specifying the formatting applied to column values.
Namespace: DevExpress.XtraGrid.Columns
Assembly: DevExpress.XtraGrid.v17.2.dll
Declaration
[XtraSerializableProperty(XtraSerializationVisibility.Content)]
[DXCategory("Appearance")]
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.
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:
using DevExpress.Utils;
// ...
colPayment.DisplayFormat.FormatType = FormatType.Numeric;
colPayment.DisplayFormat.FormatString = "c2";
colPurchaseDate.DisplayFormat.FormatType = FormatType.DateTime;
colPurchaseDate.DisplayFormat.FormatString = "D";
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the DisplayFormat property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.