Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DataViewBase.CanUnselectRow Event

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

Namespace: DevExpress.Xpf.Grid

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

NuGet Package: DevExpress.Wpf.Grid.Core

#Declaration

public event CanUnselectRowEventHandler CanUnselectRow

#Event Data

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

Property Description
CanUnselectRow Gets or sets whether an end-user can unselect the processed row.
Row Gets a data row object that corresponds to the processed cell.
RowHandle Gets the handle of a processed row.
View Gets a GridControl view to which the processed row belongs.

#Remarks

Handle the CanUnselectRow event to dynamically prevent users from unselecting particular rows.

Set the event argument’s CanUnselectRowEventArgs.CanUnselectRow property to false to prevent a user from unselecting a processed row. Use the CanUnselectRowEventArgs.Row, and CanUnselectRowEventArgs.RowHandle event argument properties to retrieve a processed row.

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

Handle the DataViewBase.CanSelectRow event to prevent end-users from selecting a particular row.

#Unselect a Cell

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

See Also