Search code examples
c#windowsuser-interfacedrag-and-droptreelist

Is it possible to have Drag and Drop in C# without moving the source to target?


I am wondering if in the realm of UI design the case exists where you drag one TreeList's item and drop onto another TreeList item only to invoke a new window (to perform some functioanlity) BUT not to actually move the source and drop it onto the target.

I have this as a requirement but I am not sure if it makes sense.

I thought Drag and Drop in a tree List is only to move one item to another branch of the tree, not to trigger a pop up. Am I mistaken? The examples I have so far seen , all move the source to the target.


Solution

  • Drag and Drop is basically a set of events that get triggered. The Drop event can be used by your code to do anything. So triggering a popup on a drop is entirely possible.

    Read this http://msdn.microsoft.com/en-us/library/ms742859.aspx for more details.

    void treeView_Drop(object sender, DragEventArgs e)
    {
       var sourceNode = (TreeNode)e.Data.GetData(typeof(TreeNode);
    
       // TODO: popup window
    }