C # WinForms DragEnter never fires

I am puzzled by this. I tried to drag and drop on a DataGridView . If you did not notice any events, I tried a simple form with a text box.

I would like to be able to drag and drop files or folders from Windows Explorer.

Something is missing for me because these events never fire. I read about DragEvents, Windows 7, and UIPI , but I still couldn't get around this.

I have no 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 like this should work. I have a clean install on WP7 64 - with all the updates, I have no protection against viruses or malware, or anything (as far as I know) that can prevent these events from firing.

+4
source share
2 answers

I had the same problem. it was only because I was debugging the run as administrator session. I think that with VISTA there is protection that prevents the transition to a privileged application.

+23
source

I found that although I ran the Forms application in debug mode from Visual Studio, this did not work. Only when I ran it outside of VS does it work perfectly. Presumably, this is also related to security in Windows 7 (and possibly in later versions).

+2
source

Source: https://habr.com/ru/post/1389884/


All Articles