DxComboBox<TData, TValue>.DisplayFormat Property

Specifies the pattern used to format the ComboBox’s display value when the editor is not focused.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

[Parameter]
[DefaultValue("")]
public string DisplayFormat { get; set; }

Property Value

Type Default Description
String

String.Empty

The format pattern.

Remarks

Use the DisplayFormat property to format the ComboBox’s display value when the editor is not focused. The specified format is applied when the ComboBox’s edit value (the Value property value) can be converted to a numeric or date-time data type. See the Format Types in .NET documentation section for more information.

NOTE

To format the ComboBox’s edit value when the editor is focused, use the EditFormat property.

The DisplayFormat property allows you to format values in one-column and multi-column ComboBoxes.

Format a One-Column ComboBox

The following example demonstrates how to apply the currency format to numeric values.

<DxComboBox Data="@Prices" @bind-Value="@CurrentPrice" DisplayFormat="C"></DxComboBox>

@code {
    IEnumerable<string> Prices = new List<string>() {
        "20.5",
        "25",
        "50",
    };

    string CurrentPrice { get; set; }
}

ComboBox DisplayFormat

Format a Multi-Column ComboBox

The code below adds three columns to a ComboBox and applies the {1} {2} format to the component’s display values. This format specifies that the editor value includes values of the following columns: FirstName (VisibleIndex = 1) and LastName (VisibleIndex = 2).

<DxComboBox Data="@Staff.DataSource"
            @bind-Value="@SelectedPerson"
            EditFormat="{1} {2}"
            DisplayFormat="Selected user: {1} {2}">
    <DxListEditorColumn FieldName="Id" Width="50px" />
    <DxListEditorColumn FieldName="FirstName" />
    <DxListEditorColumn FieldName="LastName" />
</DxComboBox>

@code {
    Person SelectedPerson { get; set; } = Staff.DataSource[0];
}

ComboBox - Multi-Column Display Format

Run Demo: ComboBox – Multiple Columns

Watch Video: ComboBox - Multiple Columns and Cascade Lists

See Also