I have a DataGridView control on my windows application form. This DataGridView is populated on the basis of a plain text file (specified by user at run time). Hence the number of columns and rows are calculated dynamically. Now the every thing works fine as expected the only issue is that my DataGridView took a lot of time to load data, is there any way to optimize the performance of DataGridView?
Hint: Normally the datagridview contians 1024 columns and almos 100 rows.
Following is the code for populating my DataGridView
dataGridView1.ColumnCount = nColumnCount;
for (int i = 0; i < CurrPageLines.Length; i++)
{
string sCurrLinecontents = CurrPageLines[i];
int n = dataGridView1.Rows.Add();
for (int j = 0; j < /*nColumnCount*/sCurrLinecontents.Length; j++)
{
dataGridView1.Rows[n].Cells[j].Value = sCurrLinecontents[j];
}
}