[VS 2008] DragDrop event not firing

S

Steve Z

We have an app with a datagridview that we allow users to drag-drop files
into - basically displaying the filename dragged in.

Works in our shop - but not at the customer site (the customer did find one
workstation that it would work on though...).

At any rate - we worked up a simple app to test this with - here it is -
Form1, DataGridView1 - that's pretty much it.

At the customer site the DRAGENTER event is firing - as the
DragDropEffects.All is being set. But when you let go of the mouse - the
DragDrop event does not fire.

What would cause my .EXE's to not permit DragDrop? Workstations are all
Windws XP Pro SP2.

Code:
Public Class Form1

Private Sub DataGridView1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop
Dim dragfiles As String() =
CType(e.Data.GetData(DataFormats.FileDrop), String())
For i As Integer = 0 To dragfiles.Count - 1
Dim vendorfile As String = dragfiles(i)
DataGridView1.Rows.Add("hi")
DataGridView1.Rows(DataGridView1.Rows.Count - 2).Cells(0).Value
= vendorfile
Next


End Sub

Private Sub DataGridView1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragEnter
e.Effect = DragDropEffects.All
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
DataGridView1.Columns.Add(0, "FileName")
End Sub
End Class
 
S

Steve Z

I changed the test app to have both a DGV and a List View on the same form.
The LV works on the customer machines

Public Class Form1

Private Sub ListView1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles ListView1.DragEnter,
MyBase.DragEnter
e.Effect = DragDropEffects.All
End Sub

Private Sub ListView1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles ListView1.DragDrop,
MyBase.DragDrop
Dim files As String() = e.Data.GetData(DataFormats.FileDrop)
Dim file As String
For Each file In files
ListView1.Items.Add(file.ToString)
Next
End Sub

Private Sub DataGridView1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop
Dim dragfiles As String() =
CType(e.Data.GetData(DataFormats.FileDrop), String())
For i As Integer = 0 To dragfiles.Count - 1
Dim vendorfile As String = dragfiles(i)
DataGridView1.Rows.Add("hi")
DataGridView1.Rows(DataGridView1.Rows.Count - 2).Cells(0).Value
= vendorfile
Next
End Sub

Private Sub DataGridView1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragEnter
e.Effect = DragDropEffects.All
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.AllowDrop = True
DataGridView1.Columns.Add(0, "FileName")
DataGridView1.AllowDrop = True
ListView1.AllowDrop = True
ListView1.View = View.SmallIcon
End Sub
End Class


Steve Z said:
We have an app with a datagridview that we allow users to drag-drop files
into - basically displaying the filename dragged in.

Works in our shop - but not at the customer site (the customer did find one
workstation that it would work on though...).

At any rate - we worked up a simple app to test this with - here it is -
Form1, DataGridView1 - that's pretty much it.

At the customer site the DRAGENTER event is firing - as the
DragDropEffects.All is being set. But when you let go of the mouse - the
DragDrop event does not fire.

What would cause my .EXE's to not permit DragDrop? Workstations are all
Windws XP Pro SP2.

Code:
Public Class Form1

Private Sub DataGridView1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop
Dim dragfiles As String() =
CType(e.Data.GetData(DataFormats.FileDrop), String())
For i As Integer = 0 To dragfiles.Count - 1
Dim vendorfile As String = dragfiles(i)
DataGridView1.Rows.Add("hi")
DataGridView1.Rows(DataGridView1.Rows.Count - 2).Cells(0).Value
= vendorfile
Next


End Sub

Private Sub DataGridView1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragEnter
e.Effect = DragDropEffects.All
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
DataGridView1.Columns.Add(0, "FileName")
End Sub
End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top