Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Treeview > Drag 'n drop databound

Not answered Drag 'n drop databound

Feed from this thread
  • Lucien avatar

    Posted on Nov 8, 2011 (permalink)

    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:

    drgevent.Data.GetData(typeof(RadTreeNode))

    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).

    Lucien.

    Reply

  • Svett Svett admin's avatar

    Posted on Nov 11, 2011 (permalink)

    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,
    Svett
    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Treeview > Drag 'n drop databound
Related resources for "Drag 'n drop databound"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]