delphivirtualtreeview

How to detect if the user is dragging nodes from another virtual treeview?


In the OnDragOver or OnDragDrop events, how to check if the user is dragging nodes of the same Virtual Treeview or of another?

DragType is dtVCL


Solution

  • In both events, you have arguments Sender and Source. Sender is the component sending the event, that is the tree above which the mouse is flying, the drag receiver. The Source is the tree from which the drag is coming.

    You can cast the Sender or Source to the actual tree you use.

    Memo1.Lines.Add(TVirtualStringTree(Sender).Name);
    Memo1.Lines.Add(TVirtualStringTree(Source).Name);