ComponentOne TreeView for WinForms
Selecting Nodes
Nodes > Selecting Nodes

To select TreeView nodes in different ways, you need to set the SelectionMode property of C1TreeView. The SelectionMode property accepts the following values from the C1TreeViewSelectionMode enumeration:

Below is the sample code snippet setting the SelectionMode property.

' set the SelectionMode property to Multi
C1TreeView1.SelectionMode = C1.Win.TreeView.C1TreeViewSelectionMode.Multi
// set the SelectionMode property to Multi
c1TreeView1.SelectionMode = C1.Win.TreeView.C1TreeViewSelectionMode.Multi;

Contiguous Selection

Non-contiguous Selection

You can also select a node by setting the Selected property of C1TreeNode to True.

The Selected property of C1TreeNode is not applicable when the SelectedMode property of C1Treeview is set to None.

The following code snippet demonstrates how to set the property.

' enable the Selected property for the first parent node
C1TreeView1.Nodes(0).Selected = True
// enable the Selected property for the first parent node
c1TreeView1.Nodes[0].Selected = true;

The node for which the property is set gets selected as shown below.

Furthermore, you can also select a node at runtime by right-clicking it. This is the default behavior of TreeView. However, you can change this behavior by setting RightClickSelect property of the C1TreeView class as false.