drag and drop as a copy, not a move

5 posts, 0 answers
  1. fredn
    fredn avatar
    14 posts
    Member since:
    May 2008

    Posted 05 Nov 2008 Link to this post

    Hi,

    Is it possible to achieve the following behavior :

    I have two TreeViews, and I want to drag an item from the first treeview and drop it to the second without removing the node of the first. It will then act as a copy and not a move.

    Thanks in advance.

  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 05 Nov 2008 Link to this post

    Hello bronv,

    Instead of removing the dragged Node from its old location to the new one, why don't you just create a new Node, copy the data from the dragged Node and insert it in the designated place?

    I guess this is all you need to do to achieve your goal.

    All the best,
    Simon
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. fredn
    fredn avatar
    14 posts
    Member since:
    May 2008

    Posted 05 Nov 2008 Link to this post

    I don't really understand your answer because the only thing I'm doing is to catch the NodeDrop event like this :

    protected void ModulesTreeView_NodeDrop(object sender, RadTreeNodeDragDropEventArgs e)  
        {  
            foreach (RadTreeNode node in e.DraggedNodes)  
            {                
                e.DestDragNode.Nodes.Add(node);  
            }          

        } 

    So, the "node" is automatically removed from my ModulesTreeView !

  4. fredn
    fredn avatar
    14 posts
    Member since:
    May 2008

    Posted 05 Nov 2008 Link to this post

    Sorry, I post my answer too fast ! Instead of adding my "node", I just create a new node and copy the "node" data into it, and it works fine...

    Just one last question, how can I prevent a node of being selected ? Indeed, I just want to do drag&drop and I don't want to see the node selection mark.

    Thanks.

  5. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 05 Nov 2008 Link to this post

    Hi bronv,

    A RadTreeNode can belong only to one RadTreeNodeCollection at a time. If a Node, belonging to one collection is added to another it will be automatically removed from the first.

    As for your next questions, you can simply call RadTreeView.ClearSelectedNodes() to clear all selected Nodes.

    I hope this helps.

    Greetings,
    Simon
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top