windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-435323ce.md
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
[DXCategory("Property Changed")]
public event SelectionChangingEventHandler SelectionChanging
<DXCategory("Property Changed")>
Public Event SelectionChanging As SelectionChangingEventHandler
The SelectionChanging event's data class is SelectionChangingEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Action | Gets an action that describes how the collection of selected rows is about to change. |
| Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
| ControllerRow | Gets the processed row handle. |
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:
gridView1.SelectionChanging += (s, e) => {
e.Cancel = e.Action == CollectionChangeAction.Add && e.ControllerRow <= 4;
};
gridView1.SelectionChanging += Function(s, e)
e.Cancel = e.Action = CollectionChangeAction.Add AndAlso e.ControllerRow <= 4
End Function
See Also