I have a DataGridView
and I fill it like this:
private void FillDataGridView(string stringTable)
{
var lines = stringTable.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
var columns = lines.First().Split('\t');
foreach (var columnName in columns)
this.dataGridView.Columns.Add(columnName, columnName);
foreach (var line in lines.Skip(1))
{
var cells = line.Split('\t');
// This operation is too slow when applied to a huge amount of rows:
this.dataGridView.Rows.Add(cells);
}
}
My problem is that Rows.Add(cells)
is too slow (I have a huge amount of data).
This is an example of the content of stringTable
:
TIME Temperature
30.03.1992 10:00:00 7.500
30.03.1992 11:00:00 9.300
30.03.1992 12:00:00 10.000
30.03.1992 13:00:00 10.400
30.03.1992 14:00:00 11.400
30.03.1992 15:00:00 11.800
...
I would like to use a BindingList
and setting it as DataSource
, which would make it much faster. The problem is that I don't know the number of columns a priori (in this example is just "TIME,Temperature", but it could be "TIME,Temperature,Rainfall,...,Other").