Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

C# drag and drop between forms

$
0
0

I've been trying to figure out how to drag and drop between two forms (i.e applications in C#).

I created two forms. One form with a treeview and the other form with a textbox. What I wanted to eventually accomplish was to be able to drag the node name from an item on the treeview (form 1) to the textbox (form2)

Therefore, I created the first form with a treeview, a few nodes and the itemdrag event. I created the second form with the dragdrop event and dragenter event and the textbox to capture the node that was dragged over.

privatevoid textBox1_DragDrop(object sender, DragEventArgs e)

{

if (e.Data.GetDataPresent(typeof(TreeNode)))

{

...e.Data.GetData(typeof(TreeNode));

}

}

Is there some way I can get the treenodes name that was dragged over to form2 using e.Data? I tried to google an answer, but I can only figure out how to do this within one form, but not two.

Any help would be much appreciated.

Thanks,


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>