Highlighting the node under the mouse in a drag and drop operation

Hello!

When doing a drag and drop operation on a treeview, how can I highlight the treenode thats under the mouse to make it clearer for the user where the dragged treenode will be moved. This is how it is in Windows Explorer.

Thanks in advance!


Answer this question

Highlighting the node under the mouse in a drag and drop operation

  • Rob_SA

    In the DragOver event of the treeview control:

    .........

    Point pt;

    pt = treeview.PointToClient(new Point(e.X, e.Y));

    TreeNode tn = tvContents.GetNodeAt(pt);

    treeview.SelectedNode = tn
    ...............

    Hope this helps!



  • Koen Vd B

    Is it in the DragEnter event that I need to do something

  • mathmo

    Thanks, this works but when using Windows Explorer I noticed the treenode does not seem to be selected when dragged over, only highlighted. Is this not possible

    Thanks again for the working example!



  • Highlighting the node under the mouse in a drag and drop operation