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

TreeViewControl.CanSelectNode Event

Occurs when a user tries to select a node and allows you to control whether a user can select a particular node.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v24.2.dll

NuGet Package: DevExpress.Wpf.Grid.Core

#Declaration

public event CanSelectNodeEventHandler CanSelectNode

#Event Data

The CanSelectNode event's data class is DevExpress.Xpf.Grid.TreeList.CanSelectNodeEventArgs.

#Remarks

Set the TreeViewControl.SelectionMode property to the Cell/Row/MultipleRow value to use the CanSelectNode event.

The following code sample does not allow users to select root nodes.

<dxg:TreeViewControl x:Name="treeview"
                     CanSelectNode="treeview_CanSelectNode"
                     SelectionMode="Row"/>
void treeview_CanSelectNode(object sender, DevExpress.Xpf.Grid.TreeList.CanSelectNodeEventArgs e) {
    e.CanSelectNode = e.Node.Level != 0;
}

Handle the CanUnselectNode event to control whether a user can unselect a particular node.

See Also