New to Telerik UI for WinForms? Download free 30-day trial

Events

RadTreeView provides a large set of events which allows you to respond to node interactions.

  • NodeAdded/NodeAdding: The events occur before and after node is added.

  • NodeRemoved/NodeRemoving: The events occur before and after node is removed.

  • NodeExpandedChanged/NodeExpandedChanging: The events occur before and after node is expanded or collapsed.

  • NodeMouseClick/NodeMouseDoubleClick: The events occur when a node is clicked or double clicked.

Since R3 2020 the NodeMouseClick/NodeMouseDoubleClick events offer one additional parameter which allows access to the original MouseEventArgs. It is necessary to cast the event arguments to RadTreeViewMouseEventArgs.

  • SelectedNodeChanging: The event occurs before a tree node is selected.

  • SelectedNodeChanged: The event occurs after the tree node is selected.

Note that SelectedNodeChanged event fires twice. For more information, you can see the Selecting Nodes article.

  • SelectedNodesChanged - the event occurs when SelectedNodes collection has been changed.
private void RadTreeView1_NodeMouseClick(object sender, RadTreeViewEventArgs e)
{
    RadTreeViewMouseEventArgs args = e as RadTreeViewMouseEventArgs;
    if (args.OriginalEventArgs.Button == MouseButtons.Right)
    {
        //TO DO
    }
}

Private Sub RadTreeView1_NodeMouseClick(ByVal sender As Object, ByVal e As RadTreeViewEventArgs)
    Dim args As RadTreeViewMouseEventArgs = TryCast(e, RadTreeViewMouseEventArgs)

    If args.OriginalEventArgs.Button = MouseButtons.Right Then
    ' TO DO
    End If
End Sub

The above events are using RadTreeViewEventArgs and RadTreeViewCancelEventArgs objects to provide you with useful information inside the events. The main difference is that you can cancel the interaction in the second case. These objects are exposing the following information:

Parameter Description
Action Indicates how the node was changed. Can have the following values: ByKeyboard; ByMouse; Unknown.
Node The node that has been changed.
TreeElement Gives the main TreeView element the node belongs to.
TreeView Returns the TreeView control that holds the current node.
Cancel Allows you to cancel the change.(Only available in the RadTreeViewCancelEventArgs object)

See Also

In this article