Back to Devexpress

FormatInfo.Format Property

corelibraries-devexpress-dot-utils-dot-formatinfo-1a649354.md

latest5.9 KB
Original Source

FormatInfo.Format Property

Gets or sets the IFormatProvider object which specifies how values should be formatted.

Namespace : DevExpress.Utils

Assembly : DevExpress.Data.v25.2.dll

NuGet Package : DevExpress.Data

Declaration

csharp
[Browsable(false)]
[DefaultValue(null)]
public virtual IFormatProvider Format { get; set; }
vb
<Browsable(False)>
<DefaultValue(Nothing)>
Public Overridable Property Format As IFormatProvider

Property Value

TypeDefaultDescription
IFormatProvidernull

The IFormatProvider object which specifies how values should be formatted.

|

Remarks

The Format property refers to the format provider which contains information on how values should be formatted according to the FormatInfo.FormatString pattern by the FormatInfo.GetDisplayText function. Format providers supply information such as the character to use as the decimal point when formatting numeric strings, or the separation character to use when formatting a DateTime object. Format providers define the characters used for formatting by the format specifiers, but do not define the specifiers themselves.

There are two ways to specify the format provider to use:

Example

The following example shows the use of the FormatInfo.Format property.

We assign a specific format provider to the FormatInfo.Format property for a date editor and this makes the control to represent date/time values based on settings of this format provider.

The following screenshot shows the date editor after executing this code.

csharp
FormatInfo fInfo = dateEdit1.Properties.DisplayFormat;
    fInfo.FormatType = FormatType.Custom;
    fInfo.FormatString = "D";
    fInfo.Format = CultureInfo.CreateSpecificCulture("fr").DateTimeFormat;
vb
Dim fInfo As FormatInfo = DateEdit1.Properties.DisplayFormat
    fInfo.FormatType = FormatType.Custom
    fInfo.FormatString = "D"
    fInfo.Format = CultureInfo.CreateSpecificCulture("fr").DateTimeFormat

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Format 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.

winforms-grid-introduce-custom-options-in-auto-filter-row/CS/WindowsApplication3/CustomGrid.cs#L64

csharp
{
    DateTime dt = DateTime.ParseExact(val, "d", column.RealColumnEdit.EditFormat.Format);
    return new BinaryOperator(column.FieldName, dt, type);

winforms-grid-introduce-custom-options-in-auto-filter-row/VB/WindowsApplication3/CustomGrid.vb#L75

vb
Try
    Dim dt As Date = Date.ParseExact(val, "d", column.RealColumnEdit.EditFormat.Format)
    Return New BinaryOperator(column.FieldName, dt, type)

See Also

FormatString

FormatType

GetDisplayText(Object)

Formatting Values

FormatInfo Class

FormatInfo Members

DevExpress.Utils Namespace