# Selecting Nodes

## Selecting a Single Node

To select a node use the **Selected** property of **RadTreeNode**. The following example demonstrates how to do it.

```C#
radTreeView1.SelectedNode = radTreeView1.Nodes[0];
```

```VB.NET
RadTreeView1.SelectedNode = RadTreeView1.Nodes(0)
```

## Selecting Multiple Nodes

To enable the multiple selection the **MultiSelect** property must be set to *true*. The default value is *false*.

| **Selection**                              | **Example**                                                                                                                                                                                                        | **Description**                                                                                                                                                                                                                                                                              |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Single Selection**                       | ![WinForms RadTreeView Single Selection](https://www.telerik.com/products/winforms/documentation/assets/e4d951759a1e9cb63e25c4b7980397cd/treeview-working-with-nodes-selecting-nodes001.png)                       | The user can select a single node by clicking the node.                                                                                                                                                                                                                                      |
| **Multiple Selection using the Shift key** | ![WinForms RadTreeView Multiple Selection using the Shift key](https://www.telerik.com/products/winforms/documentation/assets/0b839844bd60b79ac751626cb0a57f0b/treeview-working-with-nodes-selecting-nodes002.png) | To select a continuous series of multiple nodes at one time hold **Shift** and click on a node using the mouse. That will select all nodes between the first selected node and the node that was just clicked. The screenshot shows nodes selected between "Deleted Items" and "Large Mail". |
| **Multiple Selection using the Ctrl key**  | ![WinForms RadTreeView Multiple Selection using the Ctrl key](https://www.telerik.com/products/winforms/documentation/assets/d5fbfb26e1e466610deeb43b66db78e7/treeview-working-with-nodes-selecting-nodes003.png)  | To select multiple nodes in distributed throughout, hold **Ctrl** and click on each node using the mouse. That will select the clicked node or unselect the previously selected nodes. The screenshot shows the "Deleted Items" and "Send Items" nodes selected.                             |

## Selecting Multiple Nodes Programmatically

To select multiple nodes through the API, just set the Selected property of the desired nodes to true. The example below adds four nodes, then selects the last two nodes.

```C#
radTreeView1.MultiSelect = true;
RadTreeNode Node1 = new RadTreeNode("Inbox");
RadTreeNode Node2 = new RadTreeNode("Deleted Items");
RadTreeNode Node3 = new RadTreeNode("Outbox");
RadTreeNode Node4 = new RadTreeNode("Sent");
radTreeView1.Nodes.Add(Node1);
radTreeView1.Nodes.Add(Node2);
radTreeView1.Nodes.Add(Node3);
radTreeView1.Nodes.Add(Node4);
Node3.Selected = true;
Node4.Selected = true;
```

```VB.NET
RadTreeView1.MultiSelect = True
Dim Node1 As New RadTreeNode("Inbox")
Dim Node2 As New RadTreeNode("Deleted Items")
Dim Node3 As New RadTreeNode("Outbox")
Dim Node4 As New RadTreeNode("Sent")
RadTreeView1.Nodes.Add(Node1)
RadTreeView1.Nodes.Add(Node2)
RadTreeView1.Nodes.Add(Node3)
RadTreeView1.Nodes.Add(Node4)
Node3.Selected = True
Node4.Selected = True
```

## SelectedNodeChanged Event

When multiple selection functionality is turned on, the **SelectedNodeChanged** event will be called twice: first for the previously selected node first and one more time for the newly selected node. In the RadTreeViewEventArgs you can distinguish the two event firings by the **Action** property which is set to **Unknown** when the selection is cleared.

```C#
private void radTreeView1_SelectedNodeChanged(object sender, Telerik.WinControls.UI.RadTreeViewEventArgs e)
{
    if (e.Action != Telerik.WinControls.UI.RadTreeViewAction.ByMouse)
    {
        Console.WriteLine(e.Node.Text);
    }
}
```

```VB.NET
Private Sub RadTreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As RadTreeViewEventArgs)
    If e.Action <> RadTreeViewAction.ByMouse Then
        Console.WriteLine(e.Node.Text)
    End If
End Sub
```

Another approach will be to check the **Selected** property of the node. If it is true, execute your logic.

```C#
private void radTreeView2_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)
{
    if (e.Node.Selected == true)
    {
        Console.WriteLine(e.Node.Text);
    }
}
```

```VB.NET
Private Sub RadTreeView2_SelectedNodeChanged(ByVal sender As Object, ByVal e As RadTreeViewEventArgs)
    If e.Node.Selected = True Then
        Console.WriteLine(e.Node.Text)
    End If
End Sub
```

## See Also

* [Adding and Removing Nodes](https://www.telerik.com/products/winforms/documentation/controls/treeview/working-with-nodes/adding-and-removing-nodes)

* [Bring a Node into View](https://www.telerik.com/products/winforms/documentation/controls/treeview/working-with-nodes/bring-a-node-into-view)

* [Custom Filtering](https://www.telerik.com/products/winforms/documentation/controls/treeview/working-with-nodes/custom-filtering)

* [Custom Nodes](https://www.telerik.com/products/winforms/documentation/controls/treeview/working-with-nodes/custom-nodes)

* [Custom Sorting](https://www.telerik.com/products/winforms/documentation/controls/treeview/working-with-nodes/custom-sorting)

* [Events](https://www.telerik.com/products/winforms/documentation/controls/treeview/working-with-nodes/events)
