Back to Devexpress

GridColumn.DisplayFormat Property

windowsforms-devexpress-dot-xtragrid-dot-columns-dot-gridcolumn-3dcd79ff.md

latest3.9 KB
Original Source

GridColumn.DisplayFormat Property

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

Namespace : DevExpress.XtraGrid.Columns

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Format")]
[XtraSerializableProperty(XtraSerializationVisibility.Content)]
public FormatInfo DisplayFormat { get; }
vb
<DXCategory("Format")>
<XtraSerializableProperty(XtraSerializationVisibility.Content)>
Public ReadOnly Property DisplayFormat As FormatInfo

Property Value

TypeDescription
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 GridColumn.DisplayFormat.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 following topic for additional information: Formatting Cell Values.

Example

The following examples formats column values using standard format specifiers for date-time and numeric values.

The following image shows the result:

csharp
colOrderDate.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
colOrderDate.DisplayFormat.FormatString = "D";

colUnitPrice.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
colUnitPrice.DisplayFormat.FormatString = "c2";

colDiscount.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
colDiscount.DisplayFormat.FormatString = "P0";
vb
colOrderDate.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime
colOrderDate.DisplayFormat.FormatString = "D"

colUnitPrice.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
colUnitPrice.DisplayFormat.FormatString = "c2"

colDiscount.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
colDiscount.DisplayFormat.FormatString = "P0"

See Also

CustomColumnDisplayText

Format Cell Values

GridColumn Class

GridColumn Members

DevExpress.XtraGrid.Columns Namespace