Skip to main content

TableView.CanUnselectCell Event

Occurs in multiple cell selection mode when a user tries to unselect a grid cell and allows you to prevent this operation for a particular cell.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v23.2.dll

NuGet Package: DevExpress.Wpf.Grid.Core

Declaration

public event CanUnselectCellEventHandler CanUnselectCell

Event Data

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

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

Remarks

Handle the CanUnselectCell event to dynamically specify cells that users cannot unselect.

Set the CanUnselectCellEventArgs.CanUnselectCell property to false to keep the processed cell selected. Use the CanUnselectCellEventArgs.Row, CanUnselectCellEventArgs.RowHandle, and CanUnselectCellEventArgs.Column event argument properties to obtain the processed cell.

TableView CanUnselectCell

<dxg:GridControl ...
                 SelectionMode="Cell">
    <dxg:GridControl.View>
        <dxg:TableView ...
                       CanSelectCell="View_CanSelectCell"
                       CanUnselectCell="View_CanUnselectCell">
        </dxg:TableView>
    </dxg:GridControl.View>
</dxg:GridControl>
void View_CanSelectCell(object sender, CanSelectCellEventArgs e) {
    e.CanSelectCell = e.Column.FieldName != "Visits";
}
void View_CanUnselectCell(object sender, CanUnselectCellEventArgs e) {
    e.CanUnselectCell = e.Column.FieldName != "Birthday";
}

Handle the TableView.CanSelectCell event to specify cells that users cannot select.

Refer to the following help topic for more information: Cell Selection.

See Also