Quantcast
Viewing all articles
Browse latest Browse all 27206

Help DataGRidView not Bound but i cant import from TXT

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
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

but I get this error
Quote:

Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
on this line
Code:

Me.ShoppingListView.Rows.Add(SplitLine)

Viewing all articles
Browse latest Browse all 27206

Trending Articles



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