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:
- Multi: Allows you to select multiple nodes (parent or child) in TreeView. You can select multiple nodes either in a contiguous or a non-contiguous manner. To select multiple nodes in a contiguous manner, hold the SHIFT key while clicking on nodes. And to select nodes in a non-contiguous manner, hold the CTRL key while clicking on nodes.
- MultiSibling: Allows you to select multiple nodes in a contiguous or a non-contiguous manner using SHIFT or CTRL keys respectively, within a parent node only.
- None: Does not allow you to select any node in TreeView.
- Single (default value): Allows you to select only one node (parent or child) in TreeView at a time.
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.