help with D+D and TreeView

S

SteveK

I want to make a little utility that will allow me to drag a folder onto a
treeView and then poppulate the treeView with the contents of the dragged
folder. So far things aren't going well. I have set AllowDrop to true and
added an event handler for DragDrop and in that handler added a MessageBox
to alert me that something was dropped.

The event never fires. I honestly don't know what to do from here, not many
options come to mind of things to explor. Anyone have any ideas? Clues?

Thanks!
Steve
 
G

Guest

Steve,

You need a handler for DragEnter as well, this handler is used to tell the
framework that you will accept the drag&drop, and also what drop operations
you can support. for example:

private void tvContent_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
{
if( e.Data.GetDataPresent("FileDrop") )
e.Effect = DragDropEffects.Copy;
}

This example is from a similar app I wrote a few years ago, but it should
still be relevant. Note that you pass back your supported effects via
e.Effect, and you can also set this to DragDropEffects.None if your code
decides that the drop cannot be handled for some reason.

Hope this helps,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top