I'm using the following code to handle the dragenter event of my datagridview. In my project, a list of filenames (in FileDrop format) is being dragged from a third-party application onto the datagridview in my vb.net application. All works well, but there is potential for the list of filenames to contain 30,000 or more filenames. With this many filenames in the list it takes several minutes before I see the msgbox open. With no control over the information, or dataformat, provided by the third party app, is there a faster way to pass the filename list/object, or possibly a way to quickly determine how many filenames are in the list so I can prompt the user to cancel or continue the action?
Private Sub DataGridView1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragEnter
e.Effect = DragDropEffects.None
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim obj As DataObject = CType(e.Data, DataObject)
If obj.ContainsFileDropList() Then
Dim returnList As System.Collections.Specialized.StringCollection = obj.GetFileDropList()
MsgBox(returnList.Count.ToString)
End If
e.Effect = DragDropEffects.Copy
End If
End Sub