Peter King
Member
- Joined
- Sep 11, 2006
- Messages
- 15
- Programming Experience
- Beginner
Hi,
I try to read in a text file (delimited with blank space) and display the data in a DataGridView. The problem is that the file is large, with 100000 lines and each line has 10 values separated by space. I use readline to read each line and populate a row in DataGridView, with code like this:
where LineString is the line read in from the text file and is in a 1-dimentional array format.
My problem is that it is extremely slow to load the file into the DataGridView. Do I miss something that can speed up? I know in ListView, one can use ListView.beginUpdate() before loading data to speed up, but cannot find an equivalent for DataGridView.
Alternatively, is it possible to bind the text file to DataGridView? If yes, does it speed up loading data into DataGridView?
Please help!
peter
I try to read in a text file (delimited with blank space) and display the data in a DataGridView. The problem is that the file is large, with 100000 lines and each line has 10 values separated by space. I use readline to read each line and populate a row in DataGridView, with code like this:
VB.NET:
Dim fsStream As New FileStream(ListViewFileName, _
FileMode.Open, FileAccess.Read)
Dim srReader As New StreamReader(fsStream)
For i As Integer = 0 To 100000
DataGridView1.Rows.Add(New String() {i, i, i, i, i, i, i, i, i, i})
If i Mod 10000 = 0 Then MsgBox(i)
Next
where LineString is the line read in from the text file and is in a 1-dimentional array format.
My problem is that it is extremely slow to load the file into the DataGridView. Do I miss something that can speed up? I know in ListView, one can use ListView.beginUpdate() before loading data to speed up, but cannot find an equivalent for DataGridView.
Alternatively, is it possible to bind the text file to DataGridView? If yes, does it speed up loading data into DataGridView?
Please help!
peter