Skip to main content

DxListBox<TData, TValue>.SelectionMode Property

Specifies selection mode.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v25.2.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 (Default)

Users can select one List Box item at a time.

  • Use the Value property to get or set the selected item (you can use two-way data binding).
  • Handle the ValueChanged event to respond to selection changes (if you use one-way data binding).
<DxListBox Data="@Staff.DataSource"
           @bind-Value="@Value"
           TextFieldName="@nameof(Person.Text)"/>

@code{
    Person Value;
}

List Box Selects One Item

Run Demo: List Box - Overview

Multiple Selection

Users can select multiple items.

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

Users cannot select items. Use this mode when you want to display a read-only list of items, handle item clicks without selection state, or create a custom selection behavior.

@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);
}

Select Items in the UI

Users can select List Box items in the following ways:

Mouse/Touch

  • In single selection mode, click or tap an item.
  • In multiple selection mode:
    • Hold Ctrl and click items to select them individually.
    • Hold Shift to select a range of items.
    • Click checkboxes next to items (when ShowCheckboxes is true).
    • Click the Select All checkbox (when both ShowSelectAllCheckbox and ShowCheckboxes are true).

Keyboard

  • Use and arrows to focus an item.
  • Press Space to select/deselect the focused item.
  • Press Enter to trigger an item click (requires an ItemClick event handler).

Refer to List Box - Keyboard Support for more information.

Implements

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