This is a migrated thread and some comments may be shown as answers.

How to capture nodes selected and dragged from one treeview on the Other treeview node with Telerik RadTreeView?

5 Answers 101 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Rahul Khinvasara
Top achievements
Rank 1
Rahul Khinvasara asked on 26 Apr 2010, 12:08 PM
I am using Telerik RadTreeView. I have 2 treeviews on my page. I want to assign the checked nodes from the first Treeview to a Node in the Second TreeView. I dont get a event that will capture the 2nd treeview's node i.e the node that we want to drop onto. Some sample code will be useful.

Thanks in Advance.

5 Answers, 1 is accepted

Sort by
0
Dobry Zranchev
Telerik team
answered on 27 Apr 2010, 06:09 PM
Hello Rahul Khinvasara,

Thank you for contacting me.

You can subscribe for the DragStarted event of the first tree and for the DragEnded event of the second tree. When you start dragging you will use DragStarted (e.) event to keep the source node in it. When you drop the item on to the second tree you will take DragEnded event and take the target node. I hope this helps.

If you have other questions feel free to contact us.
 

Greetings,
Dobry Zranchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rahul Khinvasara
Top achievements
Rank 1
answered on 29 Apr 2010, 10:49 AM
I tried the solution provided by you. The Dragstarted Event of First tree i.e. RadTreeView1 works fine. But the Drag ended event of 2nd treeview i.e RadTreeView2 doesnt fire. It fires only if dragged within the treeview ie. within RadTreeView2 only. 

[CODE]

Private

 

Sub RadTreeView1_DragStarted(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.RadTreeViewDragEventArgs) Handles RadTreeView2.DragStarted

 

    MessageBox.Show(e.Node.Text.ToString())

 

End Sub

 

 

Private Sub RadTreeView2_DragEnded(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.RadTreeViewDragEventArgs) Handles RadTreeView1.DragEnded

 

    MessageBox.Show(e.TargetNode.Text.ToString())

 

End Sub
[\CODE]

 

0
Dobry Zranchev
Telerik team
answered on 30 Apr 2010, 09:32 AM
Hi Rahul Khinvasara,

Yes you are right you should receive the event DragEnded of the tree view that you start dragging but the target node depends of where you drop it. Sorry for the wrong explanation.

Greetings,
Dobry Zranchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Nicolaï
Top achievements
Rank 2
answered on 11 Feb 2011, 03:50 PM
Hello,

  1. Rahul Khinvasara:

Private
 Sub RadTreeView2_DragEnded(ByVal sender As System.Object, ByVal e AsTelerik.WinControls.UI.RadTreeViewDragEventArgs) 
Handles RadTreeView1.DragEnded

Notice the 1 in dragended handler, while the name of the sub says 2... 



2. But Telerik:
it would be nice with a sample for winforms drag drop between trees, illustrating the correct way to get the tag values of dragged and target node.. 
I'm truggling as well. Thought I could use the handler of tree #2 when I am dragging to tree #1. 
Dragging from tree 2 to tree 1 and using tree2.dragended: e.Node is NOT the dragged node?!


Best regards,
Nicolaï
0
Dobry Zranchev
Telerik team
answered on 17 Feb 2011, 08:56 AM
Hi Nicolai,

Thank you for writing.

The DragEnded event of RadTreeView works the following way: Let's say that you have two RadTreeViews and each of them contains some nodes. You are subscribed to the DragEnded events of both RadTreeViews. If you drag a node from tree1 to tree2, you will receive the DragEnded event of tree1. The arguments of the event contain a Node property which is the dragged node and a TargetNode property which is the target node on which you drop the dragged node.

I hope that you will find this information helpful. In case that you have other related questions, feel free to write back.

Kind regards,
Dobry Zranchev
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
Treeview
Asked by
Rahul Khinvasara
Top achievements
Rank 1
Answers by
Dobry Zranchev
Telerik team
Rahul Khinvasara
Top achievements
Rank 1
Nicolaï
Top achievements
Rank 2
Share this question
or