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

Copy node on drag-and-drop

1 Answer 55 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
paaland
Top achievements
Rank 2
paaland asked on 21 Oct 2011, 12:02 PM
I have a treeview with drag-and-drop enabled that works fine for moving the nodes around.

Now I want to add the ability to copy nodes instead of moving them if the CTRL key is held down.

I can check the CTRL key like this

ModifierKeys keys = Keyboard.Modifiers;
bool controlKeyPressed = (keys & ModifierKeys.Control) != 0;

I use the above logic to differentiate if the backends MoveNode or CopyNode service method is to be called. This works fine and the data is consistent, but the TreeView control seems to automatically remove the source upon a successful drag and drop.

I can re-insert it if CTRL was down, but I'd rather not have to do that since I might not add to the same position as it was causing the source node to "jump" around.

Any way to tell the TreeView that this is a copy operation and not a move operation? Also I'd like a way for the visual cue to display a + sign or something similar when CTRL is down.

A note: This tree is two-way bound to a object so I don't have any specific Drag/Drop event handlers. The treeview modifies the object on drag-and-drop.

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 26 Oct 2011, 10:49 AM
Hi Paal Andreassen,

I prepared a basic project for you that meets your requirements. I use PreviewDragEnded in order to implement the copy logic and DragInfo event of the RadDragAndDropManager in order to set the DragActionContent of the TreeViewDragCue when the Control is pressed. Please examine it and let us know if helps you.

Greetings,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
TreeView
Asked by
paaland
Top achievements
Rank 2
Answers by
Petar Mladenov
Telerik team
Share this question
or