There is a problem when calculating the scroll bar pages. I must calculate the pages probably based on the visible rows (an average value).
See also message from lupokehl42:
http://www.devage.com/Forum/ViewTopic.aspx?id=e7df9aabb1274635b90acea511018712
""""""""""""""""""""""
I just did some tests with the Grid (latest Version, 4.10) and found that its scrollbars behave strangely.
The attached screenshot shows the demo program that comes with SourceGrid. Only one line (the last one) is out of view. But the scrollbar makes it look as if about one third of the contents were out of view.
This makes using the Grid very weird as soon as scrolling is involved, because I always feel as if there was much more data.
After some digging in the code, I think I found the problem.
CustomScrollControl.LoadScrollArea sets verticalPage and horizontalPage. These values are later fed to the scrollbars as LargeChange, so they should tell how many rows/columns are visible at a time.
The actual values come from GridVirtual.SetScrollArea(). And for reasons I do not understand, they are calculated as Math.Max(Rows.Count / 10, 1) and Math.Max(Columns.Count / 10, 1), respectively.
This makes the values far too small, which is why the scrollbars look as if the actual visible window was much smaller.
Replacing the function with the following code did the trick (although I'm still off by a bit because this does not consider the scrollbar sizes):
private void SetScrollArea()
{
// Calculate total height in pixels
int vSize = 0;
for (int i = 0; i < Rows.Count; i++)
vSize += Rows.GetHeight(i);
// Set vertPage as the average number of visible rows
int vertPage = (vSize > 0) ? Rows.Count * this.Height / vSize : 1;
// Calculate total width in pixels
int hSize = 0;
for (int i = 0; i < Columns.Count; i++)
hSize += Columns.GetWidth(i);
// Set horPage as the average number of visible columns
int horPage = (hSize > 0) ? Columns.Count * this.Width / hSize : 1;
LoadScrollArea(vertPage, horPage);
}
"""""""""""""""""""""