Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Expand]Data Binding Common Concepts
  [Expand]Data Source Wizard
  [Expand]Expressions
  [Expand]Behaviors
  [Expand]Application Appearance
  [Expand]Filtering UI Context
  [Expand]High DPI Support
  [Expand]Scaffolding Wizard
  [Collapse]Formatting Values
    How to: Format Date-Time Values Using the LongDate Pattern
    How to: Format Date-Time Values Using a Custom Format Pattern
    How to: Format a Numeric Value according to its Sign
    How to: Add Custom Text to a Formatted String
    How to: Create a Custom Formatter to Change the Case of String Values
    How to: Create a Custom Formatter to Represent Decimal Values in Binary
    Formatting Approaches
    Members that Support the Formatting Mechanism
    Format Specifiers
    Composite Formatting
    Custom Formatting
   HTML Text Formatting
  [Expand]Menus
  [Expand]Tooltip Management
  [Expand]Saving and Restoring Layouts
   Clipboard - Copy Data and Formatting
   Version Compatibility: Default Property Values
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Members that Support the Formatting Mechanism

Expanded Format Settings

DevExpress controls that support the formatting mechanism contain properties of the FormatInfo class, which specify the settings used to format different control elements. The FormatInfo class declares two properties that are available at design time: FormatInfo.FormatType and FormatInfo.FormatString.

The FormatInfo.FormatType property has to be set to an appropriate value that identifies the type of the values that need to be formatted.

FormatInfo.FormatType value Description
FormatType.Numeric Specifies that numeric values have to be formatted.
FormatType.DateTime Specifies that date/time values have to be formatted.
FormatType.None No formatting should be applied.
FormatType.Custom Specifies that:

- string values have to be formatted using the composite formatting feature or

- values have to be formatted using a custom formatter, as described in the Custom Formatting topic.

The FormatInfo.FormatString property needs to be set to a format specifier or format string that consists of the format specifiers. This will specify the pattern according to which values should be formatted.

There is a set of predefined format specifiers to format numeric and date/time values. The output produced depends upon the regional settings of an end-user's computer. However, these specifiers allow you to format values according to the predefined formats (for instance, a date/time value can be formatted in the Short Date, Long Date or Full Date/Time form as defined in the system).

If you need greater control over formatting, you need to use custom format strings. Such format strings allow you to construct your own formatting patterns, add custom text to formatted values, specify different formats for positive and negative numeric values, etc. However, when using custom format strings, you cannot always format values so that they are correctly displayed with respect to the user's regional options. In this case, it is best to construct the format string at runtime so that regional settings can be taken into account. The Thread.CurrentThread.CurrentCulture property can be used to do this.

Note

Set the FormatInfo.FormatString only after changing the FormatInfo.FormatType property. Otherwise, your format string will be lost.

See the Format Specifiers topic for information on the available format specifiers.

Expanded Properties Exposed by the DevExpress Controls

The following table lists the properties of the FormatInfo type that are exposed by DevExpress WinForms controls.

DevExpress Control Format Property
Grid Control GridColumn.DisplayFormat - formats column values.
DevExpress Editors Library RepositoryItem.DisplayFormat - formats values within unfocused editors;

RepositoryItem.EditFormat - formats values within focused editors.

To allow end-users to enter text within editors according to specific patterns, use masks. Masks can also be used to format values even in display mode (when an editor is not active).
Tree List Control TreeListColumn.Format - formats column values.
DevExpress Vertical Grid RowProperties.Format - formats row values.
XtraPivotGrid PivotGridFieldBase.CellFormat - formats values within the Data Area;

PivotGridFieldBase.ValueFormat - formats values within the Column Header Area and Row Header Area;

PivotGridFieldBase.TotalCellFormat - formats totals;

PivotGridFieldBase.GrandTotalCellFormat - formats grand totals.

How would you rate this topic?​​​​​​​