datagridview insert new row data in next avail column

jdkoops

Member
Joined
Sep 5, 2008
Messages
17
Programming Experience
Beginner
Hi,
I'm reading a text file and splitting it to populate into the gridview. It's a basic file with 'value' = 'property' style delimiting. My question is, for comparison how can i read another file (or many if given filenames) and add the new values into the 1st avail column at row one? I don't want the 'propertly' field, just the value - as the 1st column will already have it. Can someone help please?

Here's what i have so
VB.NET:
        Dim value As String = RichTextBox1.Text

        Dim elements() As String = value.Split(New Char() {"/"c}, StringSplitOptions.RemoveEmptyEntries)
      
        For Each element As String In elements
            DataGridView1.Rows.Add(element.Split("="))

        Next


Thanks
 
I've looked everywhere still can't find an answer. What i want to do is import many csv/txt files into a datagrid. use the 1st column from first file as row headers and then skip the 1st column on the other files being imported.

I found something online that maps columns but i couldn't getting it working. The delimiter is a comma and i created a schema.ini but it always throws error.

VB.NET:
        Dim dt As New DataTable
        Dim folder = "inputFolderPath"
        Dim CnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & folder & ";Extended Properties=""text;HDR=No;FMT=Delimited"";"

        Using Adp As New OleDbDataAdapter("select CSV_1.F1 as CSV1_Col1, CSV_1.F2 as CSV1_Col2, CSV_1.F3 as CSV1_Col3, CSV_1.F4 as CSV1_Col4, CSV_1.F5 as CSV1_Col5, CSV_1.F6 as CSV1_Col6, CSV_2.F5 as CSV2_Col5, CSV_2.F6 as CSV2_Col6, CSV_2.F7 as CSV2_Col7 from [CSV_1.csv] as CSV_1 outer join [CSV_2.csv] As CSV_2 on CSV_1.F1 = CSV_2.F1", CnStr)
            Try
                Adp.Fill(dt)
            Catch ex As Exception
            End Try
        End Using

        DataGridView1.DataSource = dt

Another option is using a batch file that can merge the files doing what i want then importing that and hiding the grid columns that aren't needed (1st column after file #1) ... works ok but messes up some fields.


Can someone recommend how they would go about accomplishing such a task? Just looking for ideas.

Thanks.
 
Back
Top