corelibraries-devexpress-dot-utils-dot-formatinfo-1a649354.md
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
[Browsable(false)]
[DefaultValue(null)]
public virtual IFormatProvider Format { get; set; }
<Browsable(False)>
<DefaultValue(Nothing)>
Public Overridable Property Format As IFormatProvider
| Type | Default | Description |
|---|---|---|
| IFormatProvider | null |
The IFormatProvider object which specifies how values should be formatted.
|
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:
by setting the FormatInfo.FormatType property. This enables you to format numeric and date/time values according to the current language and regional settings. Setting FormatInfo.FormatType to FormatType.DateTime assigns the static CurrentInfo object to Format. For the FormatType.Numeric value, Format will return the static CurrentInfo object.
by setting the Format property to an object implementing the IFormatProvider interface explicitly. This can be useful if you want to format values according to a specific culture (not the current one). To use a custom format provider, you need to set the FormatInfo.FormatType property to FormatType.Custom.
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.
FormatInfo fInfo = dateEdit1.Properties.DisplayFormat;
fInfo.FormatType = FormatType.Custom;
fInfo.FormatString = "D";
fInfo.Format = CultureInfo.CreateSpecificCulture("fr").DateTimeFormat;
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
{
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
Try
Dim dt As Date = Date.ParseExact(val, "d", column.RealColumnEdit.EditFormat.Format)
Return New BinaryOperator(column.FieldName, dt, type)
See Also