以编程方式设置VerticalScrollingOffset [英] setting VerticalScrollingOffset programmatically

查看:299
本文介绍了以编程方式设置VerticalScrollingOffset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用自定义滚动条,现在面临的问题是,当我在数据网格中有数千行并一直滚动到底部时,dataGrid.VerticalScrollingOffset大约要高+ 400,谢谢.最终以dataGrid显示最后几条记录,因为它没有足够向下滚动.

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属性设置为truePanel中.

If you want to have per pixel increment, place the DataGridView in a Panel whose AutoScroll property is set to true.

这篇关于以编程方式设置VerticalScrollingOffset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆