Back to Devexpress

TreeList.SelectionChanging Event

windowsforms-devexpress-dot-xtratreelist-dot-treelist-b26ca45b.md

latest2.7 KB
Original Source

TreeList.SelectionChanging Event

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

Declaration

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

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 nodes is about to change.
CancelGets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
NodeGets the processed node.

Remarks

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:

csharp
treeList.SelectionChanging += (s, e) => {
    e.Cancel = e.Action == CollectionChangeAction.Add && e.Node.Level == 0;
};
vb
treeList.SelectionChanging += Function(s, e)
    e.Cancel = e.Action = CollectionChangeAction.Add AndAlso e.Node.Level = 0
End Function

See Also

TreeList Class

TreeList Members

DevExpress.XtraTreeList Namespace