1
我有一个Windows窗体DataGridView。我使用下面的代码填充和更新,都非常简单,并且全部都是在UI线程上完成的。Odd DataGridView垂直滚动行为
由于一些奇怪的原因,有时垂直滚动条的大小(我设置为仅在需要时才可见)并不反映可用的行数。如果我一直向下滚动,我仍然看不到最后一排。我可以通过使用下箭头键选择下面的行(并将它们放入视图中)来判断。
这可能是什么原因。我需要某种开始日期或SuspendLayout什么?该控件通过interop在MFC应用程序中嵌入。
Andy的想法如何找出这个问题?这是一个已知的错误? Google似乎并不这么认为。
这是我使用的代码。
添加或插入一个行:
int newRowIndex = insertAt;
if (insertAt < 0 || insertAt > this.dataGridView.Rows.Count)
{
newRowIndex = this.dataGridView.Rows.Add();
}
else
{
this.dataGridView.Rows.Insert(insertAt, 1);
}
移除一行:
this.dataGridView.Rows.Remove(index);
结算:
this.dataGridView.Rows.Clear();
更新一行:
this.dataGrid[0, rowIndex].Value = someString;
this.dataGrid[1, rowIndex].Value = someBool;
this.dataGrid[2, rowIndex].Value = someInt;