C# DataGridView中的自动滚动
当我向窗体上最后一个可见行下方的单元格添加值时,是否可以执行自动滚动?C# DataGridView中的自动滚动,c#,winforms,datagridview,C#,Winforms,Datagridview,当我向窗体上最后一个可见行下方的单元格添加值时,是否可以执行自动滚动? 我在DataGridView中找不到任何autoscroll属性。查找最后一个可见单元格的索引并更改FirstDisplayedScrollingRowIndex是否是唯一可行的方法?您可以使用FirstDisplayedCell属性来显示该单元格。 因为您知道向哪个单元格添加了值,所以可以这样做: dataGridView1.FirstDisplayedCell = yourCell 你可以试试这个 gv.FirstDi
我在DataGridView中找不到任何autoscroll属性。查找最后一个可见单元格的索引并更改FirstDisplayedScrollingRowIndex是否是唯一可行的方法?您可以使用
FirstDisplayedCell
属性来显示该单元格。因为您知道向哪个单元格添加了值,所以可以这样做:
dataGridView1.FirstDisplayedCell = yourCell
你可以试试这个
gv.FirstDisplayedCell = gv.Rows[gv.Rows.Count - 1].Cells[0];
这三行实际上相当于自动向下滚动
System.Int16 i_NotDisplayableRowCount = dataGridView1.RowCount - dataGridView1.DisplayedRowCount(false); // false means partial rows are not taken into acount
if (i_NotDisplayableRowCount > 0)
dataGridView1.FirstDisplayedScrollingRowIndex = i_NotDisplayableRowCount;
谢谢,它更方便。但是如何确定哪个单元格在屏幕上可见,哪个-否?