Skip to main content

DxComboBox<TData, TValue>.SelectedItemChanged Event

Fires when the ComboBox’s selected item is changed.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public EventCallback<TData> SelectedItemChanged { get; set; }

Parameters

Type Description
TData

The data item type.

Remarks

Handle the SelectedItemChanged event to process changes of the ComboBox’s selected item.

We recommend that you use the SelectedItemChanged event to access selected items’ data source objects when the following two conditions are met:

  • Two-way binding is used for the Value property.
  • The TextFieldName property is specified.
<DxComboBox Data="@Cities" 
            @bind-Value="CurrentCity" 
            TextFieldName="@nameof(City.CityName)" 
            SelectedItemChanged="@((City city) => SelectedItemChanged(city))">
</DxComboBox>

<p>@msg</p>

@code {
  List<City> Cities { get; set; } = CountryCity.Cities;
  City CurrentCity { get; set; } = CountryCity.Cities[4];
  string msg;

  void SelectedItemChanged(City city) {
    msg = "Selected item: " + city.CityName;
  }

  public class City
  {
    public int Id { get; set; }
    public string CityName { get; set; }
  }

  public static class CountryCity
  {
    private static readonly Lazy<List<City>> cities = new Lazy<List<City>>(() =>
    {
      return new List<City>() {
      new City() { Id = 0, CityName = "Washington" },
      new City() { Id = 1, CityName = "New York" },
      new City() { Id = 2, CityName = "Los Angeles" },
      new City() { Id = 3, CityName = "Berlin" },
      new City() { Id = 4, CityName = "Munich" },
      new City() { Id = 5, CityName = "Hamburg" },
      new City() { Id = 6, CityName = "Tokyo" },
      new City() { Id = 7, CityName = "Osaka" },
      new City() { Id = 8, CityName = "Yokohama" }
    };
    });
    public static List<City> Cities { get { return cities.Value; } }
  }
}

Combobox Selection changed

In all other cases, when you need to only get the value of the selected item, use the ValueChanged event instead of SelectedItemChanged.

See Also