I'm trying to populate a datagrid view with the contents af a text file i used the following code:
Private Sub Button15_Click(sender As Object, e As EventArgs) _
Handles Button15.Click
'strPath is the location of text file
Dim lines = (From line In IO.File.ReadAllLines(strPath)
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, I'm new to VB. Thanks in advance.