0
我需要使用DataGridView
控件来显示大量列。我有一个DataGridViewCell
类,它为每个单元指定一个自定义的Paint方法。我已经添加的列是这样的...DataGridView并以编程方式添加列
int ColumnCount = 5000;
DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
for (int i = 0; i < ColumnCount; i++)
{
dataGridView1.Columns.Add(new DataGridViewColumn() { CellTemplate = cell, FillWeight = 1 });
}
的问题是,这需要年龄添加的所有列,比它应该需要更长的时间。当我添加列时,我可以看到DataGridView
底部的滚动条的大小变得越来越小,就像每次添加一列时网格正在绘制每列。
有没有人知道更快的方式来添加大量的列,或者如何防止DataGridView
更新,直到所有的列已被添加?
我试过禁用调整大小,SuspendLayout()
,并设置dataGridView1.Visible = false
。
尝试创建列数组集合,然后将其添加到网格中,而不是将其添加到for循环中的网格中。 – JPReddy 2010-10-12 11:26:57