FormatInfo.FormatType Property

Gets or sets the type of formatting specified by the current FormatInfo object.

Namespace: DevExpress.Utils

Assembly: DevExpress.Data.v20.1.dll

Declaration

public virtual FormatType FormatType { get; set; }
Public Overridable Property FormatType As FormatType

Property Value

Type Description
FormatType

One of FormatType values specifying the formatting type.

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 FormatType property automatically resets the FormatString property. Thus, it is recommended to set FormatType prior to FormatString.

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.

Examples

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";
See Also