I wanted to implement a drag and drop for files into a winform app. I have AllowDrop=true
and have setup both DragEnter
and DragDrop
events.
However when trying to drag a file into the box on my form the cursor just stays as the circle with a cross and the drag enter event never fires.
I've read in other posts that windows 7 has some security features that prevent drag and drop between security level and running in debug as an admin runs the form as admin. So I tried running windows explorer as administrator and I see no difference.
Any ideas would be very helpful. Thank you.
EDIT: I've started just from a blank winform. The form itself as well as the a listbox called 'SplitListBox' have their AllowDrop property set to true. The following is code behind:
private void SplitListBox_DragDrop(object sender, DragEventArgs e)
{
var files = e.Data.GetData(DataFormats.FileDrop);
}
private void SplitListBox_DragEnter(object sender, DragEventArgs e)
{
if(e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}