corelibraries-devexpress-dot-utils-dot-formatinfo-8efabd04.md
Gets the pattern for formatting values.
Namespace : DevExpress.Utils
Assembly : DevExpress.Data.v25.2.dll
NuGet Package : DevExpress.Data
public virtual string FormatString { get; set; }
Public Overridable Property FormatString As String
| Type | Description |
|---|---|
| String |
The string representing the format pattern.
|
Use the FormatString property to specify the format pattern for formatting values.
Standard format specifiers for composing the format pattern are described in the Standard Numeric Format Strings and Date and Time Format Strings topics in MSDN.
In addition to the format string, you need to specify the format provider which contains information how to interpret the format string. This can be done by defining one of the following properties:
FormatInfo.FormatType. Use this property if you wish to format values based on the current language and regional settings (culture).
FormatInfo.Format. The property allows you to specify the format provider for a specific culture.
See Formatting Values, to learn more.
The sample code below formats display values of the date and text editors. The FormatInfo.FormatType and FormatInfo.FormatString properties of the editor’s RepositoryItem.DisplayFormat object are used for this purpose.
The image below displays the editors before and after formatting their display values.
dateEdit1.Properties.DisplayFormat.FormatType = FormatType.DateTime;
dateEdit1.Properties.DisplayFormat.FormatString = "MMMM/yyyy";
textEdit1.Properties.DisplayFormat.FormatType = FormatType.Numeric;
textEdit1.Properties.DisplayFormat.FormatString = "c2";
DateEdit1.Properties.DisplayFormat.FormatType = FormatType.DateTime
DateEdit1.Properties.DisplayFormat.FormatString = "MMMM/yyyy"
TextEdit1.Properties.DisplayFormat.FormatType = FormatType.Numeric
TextEdit1.Properties.DisplayFormat.FormatString = "c2"
The following code snippets (auto-collected from DevExpress Examples) contain references to the FormatString 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.
if(gridColumn.DisplayFormat.FormatType == FormatType.DateTime)
column.ApplyFormatting(XlCellFormatting.FromNetFormat(gridColumn.DisplayFormat.FormatString, true));
else if(gridColumn.DisplayFormat.FormatType != FormatType.None)
xaf-win-gantt-control/CS/XPO/GanttSolutionXPO/GanttSolutionXPO.Win/Editors/CustomGanttEditor.cs#L73
ganttColumn.SortIndex = column.SortIndex;
ganttColumn.Format.FormatString = column.DisplayFormat;
ganttColumn.Format.FormatType = DevExpress.Utils.FormatType.Custom;
winforms-treelist-unbound-columns/CS/TreeList_UnboundDataViaEvent/Form1.cs#L33
unbColumnMarchChange.Format.FormatType = DevExpress.Utils.FormatType.Numeric;
unbColumnMarchChange.Format.FormatString = "p2";
tlBandThisYear.Columns.Add(unbColumnMarchChange);
winforms-lookupedit-bind-to-simple-data-types/CS/LookupEdit-StandardBinding/Form1.cs#L23
gridView1.Columns["UnitPrice"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
gridView1.Columns["UnitPrice"].DisplayFormat.FormatString = "c2";
fieldPercentOfBeverages.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
fieldPercentOfBeverages.CellFormat.FormatString = "P";
pivotGridControl1.Fields.Add(fieldPercentOfBeverages);
If gridColumn.DisplayFormat.FormatType = FormatType.DateTime Then
column.ApplyFormatting(XlCellFormatting.FromNetFormat(gridColumn.DisplayFormat.FormatString, True))
ElseIf gridColumn.DisplayFormat.FormatType <> FormatType.None Then
winforms-grid-visualize-master-detail-data/VB/Form1.vb#L59
cardView1.Columns("UnitPrice").DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
cardView1.Columns("UnitPrice").DisplayFormat.FormatString = "c2"
End Sub
winforms-treelist-unbound-columns/VB/TreeList_UnboundDataViaEvent/Form1.vb#L28
unbColumnMarchChange.Format.FormatType = DevExpress.Utils.FormatType.Numeric
unbColumnMarchChange.Format.FormatString = "p2"
tlBandThisYear.Columns.Add(unbColumnMarchChange)
winforms-lookupedit-bind-to-simple-data-types/VB/LookupEdit-StandardBinding/Form1.vb#L25
gridView1.Columns("UnitPrice").DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
gridView1.Columns("UnitPrice").DisplayFormat.FormatString = "c2"
fieldPercentOfBeverages.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric
fieldPercentOfBeverages.CellFormat.FormatString = "P"
pivotGridControl1.Fields.Add(fieldPercentOfBeverages)
See Also