Skip to main content

DxListBox<TData, TValue>.SelectionMode Property

Specifies selection mode.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v25.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public ListBoxSelectionMode SelectionMode { get; set; }

Property Value

Type Description
ListBoxSelectionMode

A ListBoxSelectionMode enumeration value.

Available values:

Name Description
Single

Users can only select one List Box item at once.

Multiple

Users can select multiple items in List Box.

None

Users cannot select items in List Box.

Remarks

Single Selection

The default selection mode is Single. Users can select one List Box item at a time.

Use the Value property to access/specify the selected item in code. To respond to selection changes, handle the ValueChanged event.

Run Demo: List Box - Overview

Multiple Selection

Set the SelectionMode property to ListBoxSelectionMode.Multiple to enable multiple selection in the List Box.

Users can select multiple items in several ways:

  • Press Ctrl to select items individually or hold Shift to select a range of items.
  • Click individual items or corresponding checkboxes (available if ShowCheckboxes is enabled).
  • Click the Select All checkbox (available if both ShowSelectAllCheckbox and ShowCheckboxes are enabled). The Select All checkbox does not affect items hidden by a filter or disabled items.

Use the Values property to access/specify selected items in multiple selection mode. To respond to selection changes, handle the ValuesChanged event.

You can use SelectAllAsync() and DeselectAllAsync() methods to select/deselect all available items in code.

The following code enables multiple selection in the List Box, adds checkboxes to items, and shows the Select All checkbox:

@using StaffData

<DxListBox Data="@Staff.DataSource"
           TextFieldName="@nameof(Person.Text)"
           SelectionMode="ListBoxSelectionMode.Multiple"
           ShowCheckboxes="true"
           ShowSelectAllCheckbox="true"
           @bind-Values="@Values">
</DxListBox>

@code {
    IEnumerable<Person> Values { get; set; }
}

ListBox ShowCheckboxes

Run Demo: List Box - Multiple Selection

Disable Selection

Set the SelectionMode property to ListBoxSelectionMode.None to disable selection in the List Box.

@using BlazorApp.Data

<DxListBox Data="@Staff.DataSource"
           @bind-Values="@Values"
           TextFieldName="@nameof(Person.Text)"
           SelectionMode="ListBoxSelectionMode.None" >
</DxListBox>

@code {
    IEnumerable<Person> Values { get; set; } = Staff.DataSource.Take(1);
}

Implements

DevExpress.Blazor.IListBox<TData, TValue>.SelectionMode
See Also