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

6 posts, 0 answers
  1. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 26 Apr 2010 Link to this post

    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.
  2. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 27 Apr 2010 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 29 Apr 2010 Link to this post

    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]

     

  5. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 30 Apr 2010 Link to this post

    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.
  6. Nicolaï
    Nicolaï avatar
    160 posts
    Member since:
    Apr 2008

    Posted 11 Feb 2011 Link to this post

    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ï
  7. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 17 Feb 2011 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready