Panella
Panella

Reputation: 61

Drag & Drop from Windows Explorer into my application’s TextBox

Why is the dragdrop event never entered?

private void textBox1_DragDrop(object sender, DragEventArgs e)
{
    Array a = (Array)e.Data.GetData(DataFormats.FileDrop);

    e.Effect = DragDropEffects.All;
    Debug.WriteLine("were in dragdrop");
}

private void textBox1_DragEnter(object sender, DragEventArgs e)
{
    if (e.Data.GetDataPresent(DataFormats.FileDrop, false) == true)
    {
        e.Effect = DragDropEffects.All;
    }
}

Upvotes: 2

Views: 1443

Answers (1)

Hans Passant
Hans Passant

Reputation: 942348

Change the e.Effect assignment to DragDropEffects.Copy. Double-check that the event assignment is still there, click the lightning bolt icon in the Properties window. Sample code is available in this thread. Note that you can cast to string[] directly.

Upvotes: 1

Related Questions