开发者

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

开发者 https://www.devze.com 2023-01-12 19:20 出处:网络
Why is the dragdrop event never entered? private void textBox1_DragDrop(object sender, DragEventArgs e)

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.GetDataPr开发者_如何学Pythonesent(DataFormats.FileDrop, false) == true)
    {
        e.Effect = DragDropEffects.All;
    }
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号