Back to Devexpress

FormatInfo Class

corelibraries-devexpress-dot-utils-48359aa8.md

latest7.5 KB
Original Source

FormatInfo Class

Provides formatting settings.

Namespace : DevExpress.Utils

Assembly : DevExpress.Data.v25.2.dll

NuGet Package : DevExpress.Data

Declaration

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

The following members return FormatInfo objects:

Show 28 links

LibraryRelated API Members
Cross-Platform Class LibraryFormatInfo.Empty
PivotGridCustomTotalBase.CellFormat
PivotGridCustomTotalBase.Format
PivotGridCustomTotalBase.GetCellFormat()
PivotGridFieldBase.CellFormat
PivotGridFieldBase.DefaultDateFormat
PivotGridFieldBase.DefaultDecimalFormat
PivotGridFieldBase.DefaultPercentFormat
PivotGridFieldBase.DefaultTotalFormat
PivotGridFieldBase.GrandTotalCellFormat
PivotGridFieldBase.TotalCellFormat
PivotGridFieldBase.TotalValueFormat
PivotGridFieldBase.ValueFormat
WinForms ControlsGridColumn.DisplayFormat
GridColumn.GroupFormat
PivotGridFieldToolTips.ValueFormat
RepositoryItem.DisplayFormat
RepositoryItem.EditFormat
RepositoryItemComboBox.PopupDisplayFormat
RepositoryItemDateEdit.DisplayFormat
RepositoryItemDateEdit.EditFormat
RowProperties.DisplayFormat
TreeListColumn.Format
ASP.NET Web Forms ControlsPivotGridField.CellFormat
PivotGridField.GrandTotalCellFormat
PivotGridField.TotalCellFormat
PivotGridField.TotalValueFormat
PivotGridField.ValueFormat

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.

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.

csharp
dateEdit1.Properties.DisplayFormat.FormatType = FormatType.DateTime;
dateEdit1.Properties.DisplayFormat.FormatString = "MMMM/yyyy";
textEdit1.Properties.DisplayFormat.FormatType = FormatType.Numeric;
textEdit1.Properties.DisplayFormat.FormatString = "c2";
vb
DateEdit1.Properties.DisplayFormat.FormatType = FormatType.DateTime
DateEdit1.Properties.DisplayFormat.FormatString = "MMMM/yyyy"
TextEdit1.Properties.DisplayFormat.FormatType = FormatType.Numeric
TextEdit1.Properties.DisplayFormat.FormatString = "c2"

Implements

IXtraSerializable

Inheritance

Object ViewStatePersisterCore FormatInfo

See Also

FormatInfo Members

Formatting Values

DevExpress.Utils Namespace