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
close icon

TreeViewAdv Multiple Drag & Drop?

Hi, Do you have a sample on how to achieve dragging and dropping of multiple nodes in a TreeViewAdv?

I have been playing about with it but can only seem to get one node to drag at a time. I have allowed multiple selections in the tree.

Thanks.

5 Replies

VS Vallarasu S Syncfusion Team March 30, 2010 03:33 PM UTC

Hi,

Thanks for your interest in Syncfusion in products.

Multiple node drag and drop can be achieved by using below way.

// Get the Selected Nodes text In the array
foreach (TreeNodeAdv node in treeView.SelectedNodes)
{
index[i++] = node.Text;
}

// Nodes in the index array are then moved to destination node index.
for (i = 0; i < index.Length; i++)
{
int insertIndex = -1;
for (int j = 0; i < treeView.Nodes.Count;j++ )
{
TreeNodeAdv nodes = treeView.Nodes[j];
if (nodes.Text.Equals(index[i]))
{
insertIndex = j;
break;
}
}
treeView.Nodes[insertIndex].Move(destinationNode, NodePositions.Next);
}

Please refer the sample in the below link which illustrates the above.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=TreeNodeAdv Content-179293235.zip

Please try this and let me know if this helps.

Regards
Vallarasu S.


DA David March 30, 2010 05:53 PM UTC

Thanks but that sample doesn't work as intended.

It doesn't drop in the correct position above/below the target node, and the nodes are dropped in reverse order.


VS Vallarasu S Syncfusion Team March 31, 2010 03:23 PM UTC

Hi, David

Thank you for the update.

Please refer the modified sample from below link to achieve your requirement.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=TreeViewAdvDrogDropSample1581603886.zip

Please let me know if you have any queries.

Regards,
Vallarasu S.


DA David April 3, 2010 12:42 AM UTC

Thanks that works well.

Sorry to be a pain again, but it seems to only work when the nodes are on the root level. Once I drop them into a sub-folder node they no longer are draggable.

I'm trying to provide as much flexibility as possible so that multiple dragging/dropping can be achieved on any node level.

I've tried changing anywhere you had 'Nodes' to 'SelectedNodes' but it didn't work.

Could you please state what changes would have to be made so that multiple dragging/dropping will work on any level, and can be dropped to any level.

Thanks again for you samples.


VS Vallarasu S Syncfusion Team April 6, 2010 03:22 PM UTC

Hi, David

Thanks for your update.

Please refer the modified sample from below link for multiple node drag and drop at subnode level in TreeNodeAdv Control.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=TreeViewAdvDrogDropModifiedSample-1052327287.zip

Please let me know if you have any queries.

Regards,
Vallarasu S.

Loader.
Live Chat Icon For mobile
Up arrow icon