FormatInfo Class

Provides formatting settings.

Namespace: DevExpress.Utils

Assembly: DevExpress.Data.v19.2.dll

Declaration

public class FormatInfo :
    ViewStatePersisterCore,
    IXtraSerializable
Public Class FormatInfo
    Inherits ViewStatePersisterCore
    Implements IXtraSerializable

Remarks

There may be situations when you need to apply formatting to the values displayed by a control. For instance, you may need to display numeric values in currency format, scientific notation, etc. Controls provided by Developer Express declare properties that expose the FormatInfo object, thus enabling you to apply the required formatting. For instance, in container controls these objects are exposed via the properties of its data field objects (e.g. columns).

There are two ways you can apply formatting using an object's FormatInfo settings:

  • specify a format string using the FormatInfo.FormatString property. In this case, the FormatInfo.FormatType property should be set to FormatType.DateTime or FormatType.Numeric indicating the type of formatted values. Format strings that can be assigned to the FormatInfo.FormatString property can be found in the Standard Numeric Format Strings, Custom Numeric Format Strings, Standard Date and Time Format Strings and Custom Date and Time Format Strings topics of the Visual Studio .NET Documentation.
  • implement a custom formatter object and assign it to the FormatInfo.Format property. In this case, the FormatInfo.FormatType property should be set to FormatType.Custom. Use this formatting method when the format strings provided do not suit your needs. In this case, you can provide any formatting algorithm required.

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

Inheritance

See Also