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

Drag Drop Nodes in TreeViewAdv

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

6 Replies

AD Administrator Syncfusion Team 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.


RI Rick August 20, 2003 02:35 AM UTC

Guru Patwal, That did it. Thanks!


CS Chidd Stone March 2, 2007 03:32 PM UTC

Hi,

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?
(Syncfusion 4.4.0.51)
Any help appreciated
Chidd


MU Murugan Syncfusion Team 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.

Regards,
Murugan P.S


CS Chidd Stone March 14, 2007 12:43 PM UTC

Hi,
With
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
Chidd


MU Murugan Syncfusion Team 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.

Regards,
Murugan P.S

Loader.
Live Chat Icon For mobile
Up arrow icon