windowsforms-devexpress-dot-xtratreelist-dot-treelist-b26ca45b.md
Allows you to specify whether users can select and unselect nodes.
Namespace : DevExpress.XtraTreeList
Assembly : DevExpress.XtraTreeList.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList
[DXCategory("Property Changed")]
public event EventHandler<SelectionChangingEventArgs> SelectionChanging
<DXCategory("Property Changed")>
Public Event SelectionChanging As EventHandler(Of SelectionChangingEventArgs)
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 nodes is about to change. |
| Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
| Node | Gets the processed node. |
The SelectionChanging event is raised in multiple selection mode before a user selects/unselects a node (nodes). This event allows you to cancel the action.
The following code sample does not allow users to select root nodes:
treeList.SelectionChanging += (s, e) => {
e.Cancel = e.Action == CollectionChangeAction.Add && e.Node.Level == 0;
};
treeList.SelectionChanging += Function(s, e)
e.Cancel = e.Action = CollectionChangeAction.Add AndAlso e.Node.Level = 0
End Function
See Also