I have a panel that gets a files path using drag and drop and places the path into PathTextBox now this works with multiple files droped as once and the paths are stored as a strings.
i.e
What i need to know is say if i drag and drop 10 files on the panel at the same time how i can get the path of each file to automatically be added to a new row for in cell 3 on the DGVCode:Private Sub Drag_n_Drop_Panel_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Drag_n_Drop_Panel.DragDrop Dim theFiles() As String = CType(e.Data.GetData("FileDrop", True), String()) For Each theFile As String In theFiles PathTextBox.Text = theFile Next End Sub Private Sub Drag_n_Drop_Panel_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Drag_n_Drop_Panel.DragEnter If e.Data.GetDataPresent(DataFormats.FileDrop) Then e.Effect = DragDropEffects.Copy End If End Sub
I hope that makes sense.
EDIT
I tried this but doesnt seem to work
with Imports System.IO
Code:Private Sub Drag_n_Drop_Panel_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Drag_n_Drop_Panel.DragDrop Dim theFiles() As String = CType(e.Data.GetData("FileDrop", True), String()) For Each theFile As String In theFiles PathTextBox.Text = theFiles Me.Validate() Me.ProfilesBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.Profiles_DatabaseDataSet) Next End Sub Private Sub Drag_n_Drop_Panel_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Drag_n_Drop_Panel.DragEnter If e.Data.GetDataPresent(DataFormats.FileDrop) Then e.Effect = DragDropEffects.Copy End If End Sub




Reply With Quote