Back to Devexpress

DxComboBox<TData, TValue>.Text Property

blazor-devexpress-dot-blazor-dot-dxcombobox-2-3deca4d8.md

latest2.7 KB
Original Source

DxComboBox<TData, TValue>.Text Property

Specifies the text displayed in the edit box of the ComboBox.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(null)]
[Parameter]
public string Text { get; set; }

Property Value

TypeDefaultDescription
Stringnull

The edit box text.

|

Remarks

Set the AllowUserInput property to true to allow users to type custom values into the edit box of the ComboBox. The ComboBox editor does not add these values to the bound data source or a drop-down window. If a user enters a value equal to a drop-down window item, the editor selects the corresponding item.

The Text property specifies the text displayed in the edit box of the ComboBox. The ComboBox editor updates the Text property value and raises the TextChanged event when a user performs one of the following actions:

  • Changes the editor’s text and removes focus from the ComboBox.
  • Changes the editor’s text and presses Enter.
  • Clicks the Clear button.
  • Selects an item in the ComboBox editor’s drop-down window.

The following code snippet displays the current text and value of the ComboBox above the editor:

razor
<p class="mb-1">
    Selected item: <b>@(Value == null ? "null" : Value)</b>, Text = <b>@Text</b>
</p>

<DxComboBox Data="@Cities"
            AllowUserInput="true"
            @bind-Value="@Value"
            Text="@Text" 
            TextChanged="@OnTextChanged" />

@code {
    IEnumerable<string> Cities = new List<string>() { "London", "Berlin", "Paris", };
    string Value { get; set; } 
    string Text { get; set; } = "London";

    void OnTextChanged(string newValue) {
        Text = newValue;
    }
}

Run Demo: ComboBox - Allow User Input

Implements

DevExpress.Blazor.IComboBox<TData, TValue>.Text

See Also

DxComboBox<TData, TValue> Class

DxComboBox<TData, TValue> Members

DevExpress.Blazor Namespace