'setting VerticalScrollingOffset programmatically

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.

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.

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!



Solution 1:[1]

You can use [FirstDisplayedScrollingRowIndex][1]:

// To Scroll down
this.FirstDisplayedScrollingRowIndex = this.FirstDisplayedScrollingRowIndex + 1;

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1