0

Usually, this property is sufficent (short version):

namespace DiapoWin
{
    partial class mainWindow
    {
        private void InitializeComponent()
        {
            this.AllowDrop = true;

AllowDrop is set to true for the main Form, and the ListBox (supposed to be the target of the drag/drop).

Here are my event handlers (from this post) :

private void listImages1_DragDrop(object sender, DragEventArgs e)
{
    if (e.Data.GetDataPresent(DataFormats.FileDrop))
    {
        string[] fileNames = (string[])e.Data.GetData(DataFormats.FileDrop);
        TextDelai.Lines = fileNames;
    }
}

private void listImages1_DragEnter(object sender, DragEventArgs e)
{
    if (e.Data.GetDataPresent(DataFormats.FileDrop))
    {
        e.Effect = DragDropEffects.Copy;
    }
 }

But I still receive the forbidden mouse cursor when attempting to drop a folder (even with a file). Any ideas?

Community
  • 1
  • 1
Patator
  • 164
  • 1
  • 9
  • [How do I drag and drop files into a C# application?](http://stackoverflow.com/questions/68598/how-do-i-drag-and-drop-files-into-a-c-sharp-application) ?? – huMpty duMpty Oct 31 '14 at 16:56
  • Are you handling DragOver? http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dragover(v=vs.110).aspx – WraithNath Oct 31 '14 at 16:57
  • I just added a precision : all events handlers are created :( – Patator Oct 31 '14 at 16:59
  • hard to say without seeing full code, normally you need to specify the drag effect depending on the item being dragged – WraithNath Oct 31 '14 at 17:01
  • possible duplicate of [C# Drag drop does not work on windows 7](http://stackoverflow.com/questions/2833709/c-sharp-drag-drop-does-not-work-on-windows-7) – C-Pound Guru Nov 03 '14 at 20:55

1 Answers1

0

Okay, this post was the one to read. Closed and re-launched VisualStudio without Administrator rights, it works :(

Community
  • 1
  • 1
Patator
  • 164
  • 1
  • 9