I tried the following code which is very similar to yours and it works fine:
Private Sub ListView1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles ListView1.DragDrop
Dim Filename As String
For Each Filename In e.Data.GetData(DataFormats.FileDrop)
Dim item As New ListViewItem
item.Text = Filename
ListView1.Items.Add(item)
Next
End Sub
Private Sub ListView1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles ListView1.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop, False)) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Are you sure that you are not using threads somewhere? Is your form running
on the main thread of your application? Are you using the MTAThreadAttribute
anywhere? Which error is generated by your code?
Regards, Jakob.
"Giovanni pepe" wrote:
This is my code for Drag&Drop :
Lvw_DragDrop:
--------------------------------------------------------------------------
For Each Filename In e.Data.GetData(DataFormats.FileDrop)
ReDim Preserve SourceFiles(i)
SourceFiles(i) = CompleteFilename
i = i + 1
Next
--------------------------------------------------------------------------
Lvw_DragEnter:
------------------------------------------------------------------------
If (e.Data.GetDataPresent(DataFormats.FileDrop, False)) Then
e.Effect = DragDropEffects.Copy
End If
------------------------------------------------------------------------
This code generate an error ...
The error is disappear when i insert into code Application.ThreadException