Back to Devexpress

ColumnView.SelectionChanging Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-435323ce.md

latest2.7 KB
Original Source

ColumnView.SelectionChanging Event

Allows you to specify whether users can select and unselect rows.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Property Changed")]
public event SelectionChangingEventHandler SelectionChanging
vb
<DXCategory("Property Changed")>
Public Event SelectionChanging As SelectionChangingEventHandler

Event Data

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

PropertyDescription
ActionGets an action that describes how the collection of selected rows is about to change.
CancelGets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
ControllerRowGets the processed row handle.

Remarks

The SelectionChanging event is raised in multiple selection mode before a user selects/unselects a row (rows). This event allows you to cancel the action.

The following code sample does not allow users to select the first 5 rows:

csharp
gridView1.SelectionChanging += (s, e) => {
    e.Cancel = e.Action == CollectionChangeAction.Add && e.ControllerRow <= 4;
};
vb
gridView1.SelectionChanging += Function(s, e)
    e.Cancel = e.Action = CollectionChangeAction.Add AndAlso e.ControllerRow <= 4
End Function

See Also

ColumnView Class

ColumnView Members

DevExpress.XtraGrid.Views.Base Namespace