A newer version of this page is available. Switch to the current version.

Row Selection

  • 5 minutes to read

The GridControl allows you to select rows, nodes, and cards.


Demo: Multiple Row Selection

Requires a WPF Subscription. Download

Enable Multiple Row Selection

To enable the multiple row, card, or node selection:

  1. Check that the DataViewBase.NavigationStyle property is not set to GridViewNavigationStyle.None;
  2. Set the DataControlBase.SelectionMode property to MultiSelectMode.Row or MultiSelectMode.MultipleRow.

The DataControlBase.CurrentItem property returns the focused data item. The DataControlBase.SelectedItem property returns the first selected item (first item of the DataControlBase.SelectedItems collection). The focused row, card, or node may not be selected.


The Row and MultipleRow modes support the Selector Column.

Refer to the Select Multiple Rows topic for information on how end users can select rows in the multiple row selection mode.

Selection Availability

Handle the DataViewBase.CanSelectRow or DataViewBase.CanUnselectRow event to control whether end users can select or unselect rows, cards, or nodes. The following code sample demonstrates how to exclude rows with specified cell values from end-user selection and change appearance of these rows:

<dxg:TableView x:Name="view" NavigationStyle="Row" CanSelectRow="View_CanSelectRow" >
        <dxg:FormatCondition Expression="[Visits] >= 8" IsEnabled="True" >
            <dxg:Format Background="#FFB2B2B2"/>
void View_CanSelectRow(object sender, CanSelectRowEventArgs e) {
    e.CanSelectRow = (Convert.ToDouble(grid.GetCellValue(e.RowHandle, "Visits")) < 8);

Select Rows

API Description
DataControlBase.BeginSelection Prevents selection updates until the DataControlBase.EndSelection method is called.
DataControlBase.EndSelection Enables selection updates previously suppressed by a DataControlBase.BeginSelection method call. Forces a selection update.
DataControlBase.SelectAll Selects all rows/cards/nodes within a View.
DataControlBase.UnselectAll Unselects any selected rows/cards/nodes within a View.
DataControlBase.SelectItem Selects the specified row/card/node.
DataControlBase.UnselectItem Unselects the specified row/card/node.
DataControlBase.SelectedItem Get or sets the focused data item (if row multi-selection is disabled); or the first selected row (if row multi-selection is enabled).
DataControlBase.SelectedItems Gets or sets data objects that correspond the selected rows/nodes within a View.
DataControlBase.GetSelectedRowHandles Returns the handles of the selected rows.
DataControlBase.SelectRange Adds multiple rows/cards/nodes to the selection.
TreeListControlBase.GetSelectedNodes Returns selected nodes.
DataControlBase.SelectedItemChanged This event occurs after the GridControl's primary selected item is changed.
GridControl.SelectionChanged / TreeListControlBase.SelectionChanged This event occurs after the GridControl / TreeListControl 's selection is changed.

The following code sample demonstrates how to iterate through rows and select rows that contain the specified value:

void Button_Click(object sender, RoutedEventArgs e) {

public void SelectRowInColumn(object value) {
    for (int index = 0; index < grid.VisibleRowCount; index++) {
        int rowHandle = grid.GetRowHandleByVisibleIndex(index);
        var cellValue = grid.GetCellValue(rowHandle, "Visits");
        if (cellValue != null && cellValue.Equals(value))

A complete sample project is available at How to: Select Rows that Contain The Specified Value.

Obtain Selected Rows

To obtain selected rows/nodes or their handles, use DataControlBase.SelectedItems or DataControlBase.GetSelectedRowHandles respectively.

The following code sample shows how to process selected rows, and unselect rows where the number of visits is less than 10:

void ProcessSelectedRows(GridControl gridControl, GridViewBase view) {
    foreach (int rowHandle in gridControl.GetSelectedRowHandles()) {
        if (Convert.ToDouble(gridControl.GetCellValue(rowHandle, "Visits")) < 10)

Customize Appearance

To change a row's appearance according to its selection state, use the TableView.RowStyle / TreeListView.RowStyle property.

Use the RowControl.SelectionState property to determine the cell's state:

Member Name Description
None A row is not focused and is not selected
Focused A row is focused but is not selected
Selected A row is selected but is not focused
Highlighted A row is highlighted
FocusedAndSelected A row is focused and selected

The following code sample changes the background color of rows based on their states:

<dxg:TableView x:Name="tableView1">
        <Style TargetType="dxg:RowControl">
                <Trigger Property="SelectionState" Value="Selected">
                    <Setter Property="Background" Value="LightGreen"/>
                <Trigger Property="SelectionState" Value="Focused">
                    <Setter Property="Background" Value="Green"/>

To disable the appearance of selected rows, set the DataViewBase.EnableSelectedRowAppearance property to false.

Notes and Limitations

See Also