We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to drag and drop the TreeNodeAdv between different WinForms TreeViewAdv?

Platform: WinForms |
Control: TreeViewAdv

Drag and drop

TreeNodeAdv can be dragged and dropped between different TreeViewAdv that is placed in different forms by handling following events.

1. ItemDrag

2. DragOver

3. DragDrop

4. DragEnter

5. DragLeave


// Occurs when TreeNodeAdv drags from the TreeViewAdv
private void treeViewAdv_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
    TreeViewAdv treeViewAdv = sender as TreeViewAdv;
    // Allow to move
    DragDropEffects result = treeViewAdv.DoDragDrop(node, DragDropEffects.Move);
// Occures drop the TreeNodeAdv to the TreeViewAdv
private void treeViewAdv_DragDrop(object sender, DragEventArgs e)
    TreeViewAdv treeView = sender as TreeViewAdv;
    // Get the destination and source node.
    TreeNodeAdv sourceNode = (TreeNodeAdv)e.Data.GetData(typeof(TreeNodeAdv));
    TreeNodeAdv destinationNode = this.treeViewDragHighlightTracker.HighlightNode;
    TreeViewDropPositions dropPosition = this.treeViewDragHighlightTracker.DropPosition;
    // Move the source node based on the tracked info.
    if (destinationNode != null)
        sourceNode.Move(destinationNode, NodePositions.Next);                 
        treeView.SelectedNode = sourceNode;


' Occurs when TreeNodeAdv drags from the TreeViewAdv
Private Sub treeViewAdv_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs)
    Dim treeViewAdv As TreeViewAdv = CType(sender, TreeViewAdv)
    ' Allow to move
    Dim result As DragDropEffects = treeViewAdv.DoDragDrop(node, DragDropEffects.Move)
End Sub
' Occures drop the TreeNodeAdv to the TreeViewAdv
Private Sub treeViewAdv_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs)
     Dim treeView As TreeViewAdv = CType(sender, TreeViewAdv)
     ' Get the destination and source node.
     Dim sourceNode As TreeNodeAdv = CType(e.Data.GetData(GetType(TreeNodeAdv)), TreeNodeAdv)
     Dim destinationNode As TreeNodeAdv = Me.treeViewDragHighlightTracker.HighlightNode
     Dim dropPosition As TreeViewDropPositions = Me.treeViewDragHighlightTracker.DropPosition
     ' Move the source node based on the tracked info.
     If (Not (destinationNode) Is Nothing) Then
        sourceNode.Move(destinationNode, NodePositions.Next)
     End If
    treeView.SelectedNode = sourceNode
End Sub


C#: TreeViewAdvDragDrop_C#

VB: TreeViewAdvDragDrop_VB

Reference link: https://help.syncfusion.com/windowsforms/treeview/drag-and-drop

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile