以编程方式设置VerticalScrollingOffset [英] setting VerticalScrollingOffset programmatically
问题描述
我正在使用自定义滚动条,现在面临的问题是,当我在数据网格中有数千行并一直滚动到底部时,dataGrid.VerticalScrollingOffset
大约要高+ 400,谢谢
I'm using a custom scroll bar and the problem I'm facing now is that when I have thousands of rows in a datagrid and scroll all the way to the bottom, dataGrid.VerticalScrollingOffset
is about + 400 higher thank customScrollbar.Value
. Which ends up with dataGrid now showing last few records, because it hasn't scrolled down enough.
如果我可以设置dataGrid.VerticalScrollingOffset
值或获取dataGrid的最大垂直滚动值,那将是完美的,而我在nether上找不到任何信息.
It would be perfect if I could set dataGrid.VerticalScrollingOffset
value or get the maximum vertical scrolling value of dataGrid, I couldn't find any information on nether.
当前,我正在计算像rowCount*rowHeight
这样的最大值,它没有给出确切的最大值,因此不会一直向下滚动.有什么建议?谢谢!
Currently I'm calculating the maximum value like rowCount*rowHeight
, which doesn't give exact max value, therefore it's not scrolling down all the way. Any suggestions? Thanks!
推荐答案
您可以使用[FirstDisplayedScrollingRowIndex
] [1]:
You can use [FirstDisplayedScrollingRowIndex
][1]:
// To Scroll down
this.FirstDisplayedScrollingRowIndex = this.FirstDisplayedScrollingRowIndex + 1;
如果要按像素增加,请将DataGridView
放在AutoScroll
属性设置为true
的Panel
中.
If you want to have per pixel increment, place the DataGridView
in a Panel
whose AutoScroll
property is set to true
.
这篇关于以编程方式设置VerticalScrollingOffset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!