I'm puzzled with this. I attempted implementing drag and drop on a DataGridView
. Failing to see any events fired, I tried a simple form, with a text box.
I would like to be able to drag files or folders from Windows Explorer.
I'm missing something because these events never fire. I did read about DragEvents, Windows 7 and UIPI but I still couldn't get around this.
I'm out of ideas and I welcome your suggestions.
public Form1()
{
InitializeComponent();
this.AllowDrop = true;
textBox1.AllowDrop = true;
textBox1.DragEnter += new DragEventHandler(textBox1_DragEnter);
textBox1.DragDrop += new DragEventHandler(textBox1_DragDrop);
textBox1.DragOver += new DragEventHandler(textBox1_DragOver);
}
void textBox1_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}
void textBox1_DragDrop(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}
void textBox1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}
It seems that this should work. I have a clean install on WP7 64 - with all updates, I don't have virus or malware protection running, or anything (to my knowledge) which could prevent these events firing.
I had the same issue. it was only because I was debugging from a "run as administrator" session. I think that since VISTA there is a security that prevents from dropping to a privileged application.
I found that while I was running my Forms application in debug mode from Visual Studio, it didn't work. Only when I ran it outside of VS does it work perfectly. Presumably this is also something to do with security on Windows 7 (and possibly later versions).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With