Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TreeList.SelectionChanging Event

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

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v24.2.dll

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

#Declaration

[DXCategory("Property Changed")]
public event EventHandler<SelectionChangingEventArgs> SelectionChanging

#Event Data

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.

#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:

treeList.SelectionChanging += (s, e) => {
    e.Cancel = e.Action == CollectionChangeAction.Add && e.Node.Level == 0;
};
See Also