Back to Devexpress

DataViewBase.CanUnselectRow Event

wpf-devexpress-dot-xpf-dot-grid-dot-dataviewbase-2bde5547.md

latest3.5 KB
Original Source

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.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public event CanUnselectRowEventHandler CanUnselectRow
vb
Public Event CanUnselectRow As CanUnselectRowEventHandler

Event Data

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

PropertyDescription
CanUnselectRowGets or sets whether an end-user can unselect the processed row.
RowGets a data row object that corresponds to the processed cell.
RowHandleGets the handle of a processed row.
ViewGets 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.

xaml
<dxg:GridControl ... 
                 SelectionMode="Row">
    <dxg:GridControl.View>
        <dxg:TableView ...
                       CanUnselectRow="tableView_CanUnselectRow"/>
    </dxg:GridControl.View>
</dxg:GridControl>
csharp
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

Row Selection

DataViewBase Class

DataViewBase Members

DevExpress.Xpf.Grid Namespace