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

Drag 'n drop databound

1 Answer 77 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Lucien asked on 08 Nov 2011, 09:33 PM
Hi all,

Due to the current lack of support of the RadtreeView for automatic drag and drop when the control is databound, to I am trying to "roll my own". However, I got stuck on a few things, so I really hope someone can help me out.

I have subclassed the RadTreeView, RadTreeViewElement and TreeViewDragDropService classes and am implementing my own versions of OnDragEnter and OnDragDrop. I am assuming that the DragDrop event is the one that I need to override in order to find out on which node the dragged one is dropped.

I can easily find out what node is being dragged by using the value returned in the Data object as below:


That works fine. However, I am failing to (1) find out what node it is dropped on and (2) what the databound item is for that node. When I use:

var targetNode = this.GetNodeAt(drgevent.X, drgevent.Y)

it always returns null, and I don't see any method or property that returns the item a node is bound to. I was hoping for something similar to the one in the DataGridView (row.DataBoundItem). Is there anything like that, and what do i do to get the node that the dragged item is dropped on?

Thanks in advance (I have been tearing my hair out about this for far too long).


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 11 Nov 2011, 09:16 AM
Hello Lucien,

You should convert the X and Y screen coordinates in client coordinates. You can use the following code snippet: 

C# Version:

RadTreeView treeView;
Point point = new Point(e.X, e.Y);
point = treeView.PointToClient(point);
RadTreeNode node = treeView.GetNodeAt(point);

VB.NET Version:
Dim point As New Point(e.X, e.Y)
point = treeView.PointToClient(point)
Dim node As RadTreeNode = treeView.GetNodeAt(point)

Best wishes,
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question