Skip to main content
All docs
V25.1

ComboBox - Buttons

  • 3 minutes to read

The DevExpress Blazor ComboBox component allows you to show the Clear button, hide built-in drop-down button, and add custom command buttons.

Clear Button and Placeholder

Set the ClearButtonDisplayMode property to Auto to show the Clear button when the editor has a non-null value. Users can click this button to clear the editor’s value (set it to null).

Use the NullText property to display the prompt text (placeholder) in the editor when its value is null.

ComboBox NullValue

<DxComboBox NullText="Select a country..."
            Data="@CountryData.Countries"
            @bind-Value="@CurrentCountry"
            TextFieldName="@nameof(Country.CountryName)"
            ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto">
</DxComboBox>

@code {
    Country CurrentCountry { get; set; } = CountryData.Countries[1];
}

Run Demo: ComboBox – Clear Button and Placeholder

Note

If you use the EditBoxDisplayTemplate property and need to show the clear button and placeholder, you should also add a DxInputBox object to the template markup.

Hide Built-In Drop-Down Button

Set the ShowDropDownButton property to false to hide the built-in button that invokes a drop-down menu. If you need a custom button, you can add a new command button.

Add Command Buttons

You can add custom command buttons to the ComboBox. Refer to Command Buttons for more information.

The following code snippet adds the Add Employee button to the ComboBox.

<DxComboBox Data="@Data"
            TextFieldName="@nameof(Employee.Text)"
            @bind-Value="@SelectedEmployee"
            CssClass="dx-demo-editor-width">
    <Buttons>
        <DxEditorButton IconCssClass="editor-icon editor-icon-add"
                        Tooltip="Add an employee"
                        Click="@(_ => OnButtonClick())" />
    </Buttons>
</DxComboBox>

@code{
    IObserver<string> toasterRef;
    IEnumerable<Employee> Data { get; set; }
    Employee SelectedEmployee { get; set; }
    bool AddEmployeePopupVisible { get; set; }
    protected override async Task OnInitializedAsync() {
        Data = await NwindDataService.GetEmployeesAsync();
        SelectedEmployee = Data.FirstOrDefault();
    }
    void OnButtonClick() {
        AddEmployeePopupVisible = true;
    }
    void OnEmployeeAdded(Employee newEmployee) {
        AddEmployeePopupVisible = false;
        if (newEmployee != null) {
            Data = Data.Append(newEmployee);
        }
    }
}

ComboBox - Custom Command Button

Run Demo: Editors - Command Buttons