Back to Devexpress

DataViewBase.CanSelectRow Event

wpf-devexpress-dot-xpf-dot-grid-dot-dataviewbase-0bc11a17.md

latest3.4 KB
Original Source

DataViewBase.CanSelectRow Event

Occurs in multiple row select mode when an end-user tries to select a grid row (node) and allows you to prevent selecting a particular row (node).

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public event CanSelectRowEventHandler CanSelectRow
vb
Public Event CanSelectRow As CanSelectRowEventHandler

Event Data

The CanSelectRow event's data class is CanSelectRowEventArgs. The following properties provide information specific to this event:

PropertyDescription
CanSelectRowGets or sets whether an end-user can select the processed row.
RowGets a data row object that corresponds to the processed row (or treelist node).
RowHandleGets the handle of a processed row.
ViewGets a GridControl view to which the processed row belongs.

Remarks

Handle the CanSelectRow event to dynamically prevent users from selecting particular rows.

Set the event argument’s CanSelectRowEventArgs.CanSelectRow property to false to prevent a user from selecting a processed row. Use the CanSelectRowEventArgs.Row and CanSelectRowEventArgs.RowHandle event argument properties to retrieve a processed row.

xaml
<dxg:GridControl ... 
                 SelectionMode="Row">
    <dxg:GridControl.View>
        <dxg:TableView ...
                       CanSelectRow="tableView_CanSelectRow"/>
    </dxg:GridControl.View>
</dxg:GridControl>
csharp
private void tableView_CanSelectRow(object sender, DevExpress.Xpf.Grid.CanSelectRowEventArgs e) {
    if (((Item)e.Row).Name == "John") {
        e.CanSelectRow = false;
    }
}

Handle the DataViewBase.CanUnselectRow event to prevent end-users from unselecting a particular row.

Select a Cell

Handle the TableView.CanSelectCell (TreeListView.CanSelectCell for the TreeListView) event to prevent users from selecting a particular cell.

See Also

Row Selection

DataViewBase Class

DataViewBase Members

DevExpress.Xpf.Grid Namespace