Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27083

auto add and fill dataset DGV Rows

$
0
0
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
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 = 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

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 DGV

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


Viewing all articles
Browse latest Browse all 27083


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>