Skip to main content

FormatInfo.FormatString Property

Gets the pattern for formatting values.

Namespace: DevExpress.Utils

Assembly: DevExpress.Data.v24.2.dll

Declaration

public virtual string FormatString { get; set; }

Property Value

Type Description
String

The string representing the format pattern.

Remarks

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:

  1. FormatInfo.FormatType. Use this property if you wish to format values based on the current language and regional settings (culture).

    Note

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

  2. FormatInfo.Format. The property allows you to specify the format provider for a specific culture.

See Formatting Values, to learn more.

Example

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.

Formatting - Standard

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.

See Also