Text file with a DataGrid
-
Does anybody know anything about using a text file with a DataGrid? I have a tab-delimited text file that I would like to load into a DataGrid and the only information that I can find talks about using a database.:confused: What I would like to do is load all lines with no tabs into column 1, load all lines with one tab into column 2, load all lines with two tabs into column 3, etc. The number of tabs will vary so I would like to be able to create columns as needed (on the fly). Example: Data in column 1 (one Tab) Data in column 2 Data in column 1 (one Tab) Data in column 2 (two tabs) Data in column 3 Data in column 1 Thanks Brad
-
Does anybody know anything about using a text file with a DataGrid? I have a tab-delimited text file that I would like to load into a DataGrid and the only information that I can find talks about using a database.:confused: What I would like to do is load all lines with no tabs into column 1, load all lines with one tab into column 2, load all lines with two tabs into column 3, etc. The number of tabs will vary so I would like to be able to create columns as needed (on the fly). Example: Data in column 1 (one Tab) Data in column 2 Data in column 1 (one Tab) Data in column 2 (two tabs) Data in column 3 Data in column 1 Thanks Brad
You will need to specify weather you are using VB6 or .NET, the code willbe quiet different. Thanks, Daryl
-
You will need to specify weather you are using VB6 or .NET, the code willbe quiet different. Thanks, Daryl
-
Daryl Morgans wrote: You will need to specify weather you are using VB6 or .NET I'm running .NET. Brad
What you will need to do is create a datatable to store the file in. The following should get you started. Dim dt As New DataTable("MyTable") Dim dc As New DataColumn("Column1") Dim rw As DataRow rw = dt.NewRow() rw("Column1") = SomeValue dt.Rows.Add(rw) MyDataGrid.Datasource = dt
-
What you will need to do is create a datatable to store the file in. The following should get you started. Dim dt As New DataTable("MyTable") Dim dc As New DataColumn("Column1") Dim rw As DataRow rw = dt.NewRow() rw("Column1") = SomeValue dt.Rows.Add(rw) MyDataGrid.Datasource = dt
Cool! That looks like it will get me going in the right direction. Thanks Daryl ;)