Thanks for the sample,
I've tested your sample and found that using BeginUpdate/EndUpdate pair.
This is incorrect code:
[c#]
private void btnAddElements_Click(object sender, EventArgs e)
{
grid.BeginUpdate();
Random rnd = new Random();
for (int i = 0; i < 5; i++)
{
SetCellValue(i, \"Bid Qty\", rnd.Next(int.MaxValue));
SetCellValue(i, \"Bid Price\", rnd.Next(int.MaxValue));
SetCellValue(i, \"Ask Qty\", rnd.Next(int.MaxValue));
SetCellValue(i, \"Ask Price\", rnd.Next(int.MaxValue));
}
grid.EndUpdate();
}
Use following code (without BeginUpdate/EndUpdate):
[c#]
private void btnAddElements_Click(object sender, EventArgs e)
{
Random rnd = new Random();
for (int i = 0; i < 5; i++)
{
SetCellValue(i, \"Bid Qty\", rnd.Next(int.MaxValue));
SetCellValue(i, \"Bid Price\", rnd.Next(int.MaxValue));
SetCellValue(i, \"Ask Qty\", rnd.Next(int.MaxValue));
SetCellValue(i, \"Ask Price\", rnd.Next(int.MaxValue));
}
}
or use BeginInit/EndInit:
[c#]
private void btnAddElements_Click(object sender, EventArgs e)
{
grid.BeginInit();
try
{
Random rnd = new Random();
for (int i = 0; i < 5; i++)
{
SetCellValue(i, \"Bid Qty\", rnd.Next(int.MaxValue));
SetCellValue(i, \"Bid Price\", rnd.Next(int.MaxValue));
SetCellValue(i, \"Ask Qty\", rnd.Next(int.MaxValue));
SetCellValue(i, \"Ask Price\", rnd.Next(int.MaxValue));
}
}
finally
{
grid.EndInit();
}
}