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

drag and drop as a copy, not a move

4 Answers 98 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
fredn
Top achievements
Rank 1
fredn asked on 05 Nov 2008, 10:57 AM

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.

4 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 05 Nov 2008, 03:17 PM
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.
0
fredn
Top achievements
Rank 1
answered on 05 Nov 2008, 03:41 PM

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 !

0
fredn
Top achievements
Rank 1
answered on 05 Nov 2008, 03:46 PM

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.

0
Simon
Telerik team
answered on 05 Nov 2008, 05:17 PM
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.
Tags
TreeView
Asked by
fredn
Top achievements
Rank 1
Answers by
Simon
Telerik team
fredn
Top achievements
Rank 1
Share this question
or