FormatInfo.GetDisplayText(Object) Method

Gets the value formatted according to the format pattern and using the format provider settings.

Namespace: DevExpress.Utils

Assembly: DevExpress.Data.v19.2.dll

Declaration

public virtual string GetDisplayText(
    object val
)
Public Overridable Function GetDisplayText(
    val As Object
) As String

Parameters

Name Type Description
val Object

The value to format.

Returns

Type Description
String

The text representation of the specified value according to settings of the current FormatInfo object.

Remarks

You can use the GetDisplayText function to format a value passed as the function parameter according to the format pattern and by using the settings of a format provider. The format pattern is specified by the FormatInfo.FormatString property.

The format provider is obtained from FormatInfo.Format.

The FormatInfo.Format provider can be specified implicitly by setting the FormatInfo.FormatType property. This can be useful if you wish to format values based on the current language and regional settings (culture). If you need to format values based on a specific culture, you can assign a format provider to FormatInfo.Format explicitly.

Refer to the FormatInfo.Format for an example.

Examples

The code below specifies the format type and format string for a text editor designed to display currency values. For this purpose, the FormatInfo.FormatType and FormatInfo.FormatString properties are used respectively.

However in this example, we use the specified format settings to format a custom value (1099.99) via the FormatInfo.GetDisplayText function. The result ($1,100) is displayed within a label.

    FormatInfo fInfo = textEdit1.Properties.DisplayFormat;
    fInfo.FormatType = FormatType.Numeric;
    fInfo.FormatString = "c0";
    label1.Text = fInfo.GetDisplayText(1099.99);
See Also