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

Get the treenode under cursor

1 Answer 95 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
david
Top achievements
Rank 1
david asked on 06 Feb 2009, 01:36 PM
I need to drag an image into a treeview and when a drop the image a node must be made with
the imagename.
I can drag the image an drop it on the treeview but how can I find the node i have selected for the drop??

the treeview and the image are on a grid and i''m using the draganddropmanager

david.

is it possible to create a function like GetNodeAt(point mouseposition) ?

1 Answer, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 10 Feb 2009, 04:01 PM
Hi david,

The drag&drop uses routed events so if you set the IsDropAllowed to each item, so you will be able to handle the DropQuery event for each TreeViewItem by adding a handler at the TreeView. The routed events will travel from each item that your mouse is over, so first an event will travel from the most-nested treeViewitem down the other treeViewItems through the TreeView down to the application root.

You can handle the event at any point. If the event remains unhandled, the DragDrop will look for another element under the mouse that can accept a drop, e.g. the parent TreeViewItem of the aforementioned item.

If you would like to "choose" the item as the destination, make sure that the QueryResult of the EventArgs is set to true and that the event is handled (i.e. no other handler will have a say).

Then, when you handle the DropInfo event there you will have both the e.Options.Source & e.Options.Destination you have agreed to earlier (i.e. there is no need to add variables holding the item for the specific picture).

treeViewA.AddHandler(RadDragAndDropManager.DragQueryEvent, new EventHandler<DragDropQueryEventArgs>(OnOrganisationTreeDragQuery), false); 

I have attached an example for dragging items between TreeViews with some logic.

Regards,

Miroslav
the Telerik team

 


Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
DragAndDrop
Asked by
david
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Share this question
or