hi
im trying to populate a datagrid view with the contents af a text file i used the following code:

 Private Sub Button15_Click(sender As System.Object, e As System.EventArgs) Handles Button15.Click
        Dim lines = (From line In IO.File.ReadAllLines(strPath) _'strPath is the location of text file
                          Select line.Split(CChar(vbTab))).ToArray

        For x As Integer = 0 To lines(0).GetUpperBound(0)
            dgQuotation.Columns.Add(lines(0)(x), lines(0)(x))
        Next
        For x As Integer = 1 To lines.GetUpperBound(0)
            dgQuotation.Rows.Add(lines(x))
        Next
    End Sub

but every time i run the program i get the following run time error:
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
please help im new to vb so i dont know how to solve this one thanks in advance

It sounds like you've set the DataSource somewhere. Remove that and this should work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.