Back to Devexpress

TreeViewControl.CanSelectNode Event

wpf-devexpress-dot-xpf-dot-grid-dot-treeviewcontrol-31248144.md

latest2.1 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public event CanSelectNodeEventHandler CanSelectNode
vb
Public Event CanSelectNode As CanSelectNodeEventHandler

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.

xaml
<dxg:TreeViewControl x:Name="treeview"
                     CanSelectNode="treeview_CanSelectNode"
                     SelectionMode="Row"/>
csharp
void treeview_CanSelectNode(object sender, DevExpress.Xpf.Grid.TreeList.CanSelectNodeEventArgs e) {
    e.CanSelectNode = e.Node.Level != 0;
}
vb
Private Sub treeview_CanSelectNode(ByVal sender As Object, ByVal e As DevExpress.Xpf.Grid.TreeList.CanSelectNodeEventArgs)
    e.CanSelectNode = e.Node.Level <> 0
End Sub

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

See Also

TreeViewControl Class

TreeViewControl Members

DevExpress.Xpf.Grid Namespace