This one is very weird:
My app works just fine, but suddenly the damn ListView control's events are not raised any more. It just comes and goes without any clear reason. (Obviously) I've set the AllowDrop property to True and handled the DragEnter, DragOver and DragDrop events as follows:
Private Sub lstApplications_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lstApplications.DragDrop, Me.DragDrop
m_fileNames = CType(e.Data.GetData(DataFormats.FileDrop), String())
mnuType.Show(Cursor.Position, ToolStripDropDownDirection.BelowLeft)
End Sub
Private Sub lstApplications_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lstApplications.DragEnter, Me.DragEnter, lstApplications.DragOver, Me.DragOver
If chkMode.Checked OrElse Not e.Data.GetDataPresent(DataFormats.FileDrop, True) Then
e.Effect = DragDropEffects.None
Else
e.Effect = DragDropEffects.Copy
End If
End Sub
It doesn't matter what code I wrote in these two methods because none of the events are raised. Is there anything I'm missing here?
I run the same app on another machine and it worked just fine. I then restarted my own machine and everything started working again. I'm not sure, but seems like something was wrong with Windows.
I just had hours of misery with a similar problem. three mandatory requirements for drag and drop to work:
AllowDrop="True"
, you don't need this for the entire App, just the element you want want to enable.Background="Transparent"
will do.I've had this problem when running Visual Studio 2008 on Windows 7. VS2008 must run with admin privileges on Windows 7, so I'm running it as a different user. I'm pretty sure this prevents drag 'n' drop working as the application runs fine when run as an app, but drag 'n' drop won't work when being run from Visual Studio.
Just remembered we have indeed seen this before, long time ago.
I believe it happens like this:
Drag and drop works fine until some user code throws an exception during a drag and drop operation.
The exception will be eaten; you won't get any error dialog (try it yourself and see). After this point, the drag and drop will stop working.
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