Hey All,
I'm writing a program in which I need to populate a DataGridView table. I have never before used one of these but I get the impression that it works kind of like a pivot table in excel. I would like to populate the table with data from a delimited text file. My initial research suggested that you could add information from the text file to a BindingList, and then use the BL as the datasource for the DGV. Well I tried that and it goes through the motions but it leaves the DGV table cells blank. Here's the code. I am clearly doing something wrong. Here's hoping you know what it is. Oh I suppose it's worth mentioning that I tried a regular dim list = new list(of array), first and got nothing then I moved to a BindingList of string.
I'm writing a program in which I need to populate a DataGridView table. I have never before used one of these but I get the impression that it works kind of like a pivot table in excel. I would like to populate the table with data from a delimited text file. My initial research suggested that you could add information from the text file to a BindingList, and then use the BL as the datasource for the DGV. Well I tried that and it goes through the motions but it leaves the DGV table cells blank. Here's the code. I am clearly doing something wrong. Here's hoping you know what it is. Oh I suppose it's worth mentioning that I tried a regular dim list = new list(of array), first and got nothing then I moved to a BindingList of string.
Public Shared Function OpenText4(Optional ByVal path As String = "SOMEPATH.txt") As System.IO.StreamReader OpenText4 = System.IO.File.OpenText(path) Dim fullfilestring As String Dim c1() As String Dim Blist = New BindingList(Of String) Dim ListBindingSource As New BindingSource Do Until OpenText4.Peek = -1 For Each row In path fullfilestring = OpenText4.ReadLine If fullfilestring = Nothing Then Else c1 = fullfilestring.Split(",") Blist.Add(c1) End If Next Loop OpenText4.Close() ListBindingSource.DataSource = Blist Try With FrmInsInf.DGV1 .AutoGenerateColumns = False .DataSource = ListBindingSource End With Catch ex As Exception End Try End Function End Class
Last edited by a moderator: