0

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;
    }
Doug E Fresh
  • 820
  • 8
  • 22
  • 1
    Post the code that duplicates the problem for us. – LarsTech Sep 03 '15 at 17:39
  • I posted the code. It is a simple block and mirrored in almost every tutorial out there on drag n drop. I suspect my issue may be an environment or advanced security issue. – Doug E Fresh Sep 03 '15 at 17:47
  • Code works for me. `...drag enter event never fires` Do you have the event wired up? – LarsTech Sep 03 '15 at 17:57
  • Yeah I created the method via the event properties in designer. I've tried running both debug and release and dragging from explorer run as admin. What other security issues might I be facing? – Doug E Fresh Sep 03 '15 at 18:00
  • 1
    Is your application or visual studio running as administrator? If yes, run them as a standard user and see if the problem persists. Because you can't drag/drop to an admin application from other apps (explorer, etc). – Sriram Sakthivel Sep 03 '15 at 18:14
  • Ok so if I run visual studio as a default user it works! However if I run explorer window (that I'm dragging from) as administrator I read that would work and it doesn't. – Doug E Fresh Sep 03 '15 at 18:17
  • Is there a way to have visual studio run the debug program as a specific user? – Doug E Fresh Sep 04 '15 at 13:58

0 Answers0