I have a small and simple Winform app which contains a Textbox with the AllowDrop
property set to true. I'm handling the DragDrop
and DragEnter
events as such:
Private Sub txtFile_DragEnter(sender As Object, e As DragEventArgs) Handles txtFile.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Sub txtFile_DragDrop(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles txtFile.DragDrop
Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
If Not files Is Nothing AndAlso files.Length > 0 Then
txtFile.Text = files.First()
End If
End Sub
The problem I'm having is that the textbox will not accept a file drop when I F5 debug, instead I get the 'No' cursor. If I end debugging and run the executable from the /bin folder, it works as expected.
Is there something specific about Visual Studio debugging which would prevent filedrops from working, or do I need to change any code for debugging?