i have a txt file that i want to import into a DGV that i didnt bind to anything but vb says its bound. Heres my code
but I get this error
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
on this line
Code:
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
Dim fName As String = "c:\ShoppingList.txt"
Dim TextLine As String = ""
Dim SplitLine() As String
If System.IO.File.Exists(fName) = True Then
Dim objReader As New System.IO.StreamReader(fName)
Do While objReader.Peek() <> -1
TextLine = objReader.ReadLine()
SplitLine = Split(TextLine, ",")
Me.ShoppingListView.Rows.Add(SplitLine)
Loop
Else
MsgBox("File Does Not Exist")
End If
End Sub
Quote:
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
Code:
Me.ShoppingListView.Rows.Add(SplitLine)