FormatInfo.FormatType Property
Gets or sets the type of formatting specified by the current FormatInfo object.
Namespace: DevExpress.Utils
Assembly: DevExpress.Data.v24.1.dll
NuGet Package: DevExpress.Data
#Declaration
[XtraSerializableProperty]
public virtual FormatType FormatType { get; set; }
#Property Value
Type | Description |
---|---|
Format |
One of Format |
Available values:
Name | Description |
---|---|
None | No formatting is performed. Setting the |
Numeric | Specifies that values should be formatted as numbers. Setting Also Format |
Date |
Specifies that values should be formatted as the Date Setting |
Custom | Use Custom to format string values. Use Custom when assigning a custom IFormat Setting |
#Remarks
Use the FormatType and FormatInfo.FormatString properties to format values based on the current language and regional settings (culture). FormatType specifies the type of values to be formatted. FormatInfo.FormatString specifies a format pattern appropriate for the current FormatType value. You can refer to the Standard Numeric Format Strings and Date and Time Format Strings topics in MSDN for information on format specifiers.
Note
Changing the Format
Setting the FormatType property changes the format provider used when formatting values by the FormatInfo.GetDisplayText function.
Format providers supply information such as the character to use as the decimal point when formatting numeric strings and the separation character to use when formatting a DateTime object. The FormatInfo.Format property specifies the format provider to use.
You can change the FormatInfo.Format property explicitly by assigning a IFormatProvider object. This can be useful if you wish to format values according to a specific culture (not the current one). In this case, you also need to set the FormatType property to FormatType.Custom.
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.
dateEdit1.Properties.DisplayFormat.FormatType = FormatType.DateTime;
dateEdit1.Properties.DisplayFormat.FormatString = "MMMM/yyyy";
textEdit1.Properties.DisplayFormat.FormatType = FormatType.Numeric;
textEdit1.Properties.DisplayFormat.FormatString = "c2";
#Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the FormatType 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.