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

Drag Drop Nodes in TreeViewAdv

Thread ID:





6386 Aug 11,2003 05:18 PM UTC Mar 14,2007 11:29 PM UTC WinForms 6
Tags: Tools
Asked On August 11, 2003 05:18 PM UTC

I'm have a single TreeViewAdv and need to allow or disallow a node being move based on the node being dragged and where it is being dropped. I "carry" the node type in the tag. The problem I'm having is that when I get the DragOver or DragDrop events I can't get the data from e.Data.GetData. I always get a null. I thought the object would be of type TreeNodeAdv but I get null back. I also tried object and a string with a conversion to see if I could get something but that didn't work either. Any ideas? Thanks

Administrator [Syncfusion]
Replied On August 14, 2003 06:08 PM UTC

You can use code given below to accomplish this. private void treeViewAdv2_DragOver(object sender, System.Windows.Forms.DragEventArgs e) { TreeNodeAdv[] tnas = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[]; } The e.Data.GetData method here returns an array of TreeNodeAdv and not just a single TreeNodeAdv. This is done to take care of situations in which multiple nodes maybe dragged/dropped. Let me know if this is the information you are looking for. Regards, Guru Patwal.

Replied On August 20, 2003 02:35 AM UTC

Guru Patwal, That did it. Thanks!

Chidd Stone
Replied On March 2, 2007 03:32 PM UTC


I tried using this line code in the DragOver event:
nodesBeingDragged = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[];

but it returns null: Quick watch in VS2003 shows only one TreeNodeAdv in the data although I select multiple nodes. Have set property SelectionMode to MultiSelectSameLevel but have I forgotten something?
Any help appreciated

Murugan [Syncfusion]
Replied On March 2, 2007 09:33 PM UTC

Hi Chidd,

Herewith I have attached the sample for your requirement. Please refer to the sample and let me know if it helps you.

tree drag drop

Thank you for using Syncfusion products.

Murugan P.S

Chidd Stone
Replied On March 14, 2007 12:43 PM UTC

TreeNodeAdv[] nodes = e.Item as TreeNodeAdv[];
in the treeViewAdv1_ItemDrag event I can get all treenodes if there is more than one.
Thanks for your help

Murugan [Syncfusion]
Replied On March 14, 2007 11:29 PM UTC

Hi Chidd,

I have tried the issue. But it is working fine here. Could you please send your sample? We will try to modify the sample and send you the resolved one.

Thanks for your patience.

Murugan P.S


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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
Live Chat Icon