Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm having trouble with the max position of a horizontal scrollbar. I'm creating a grid and need to set the .page and .max parameters dynamically
because user could resize the columns (each column can be resized). And I also don't want scrollbars to show up if scrolling is not necessary.


background:

Each column can be a different size, I'm using pixels as the horizontal currency.
Initially (for this example) I have columns of 103, 280, 360 pixels = 743 total pixels.
The page size is the client area's pixels (rcClient.Width() = 431).

When I set the max size(743) and page size(431), I do not have enough scroll room to scroll to the last column.

Just not understanding how to go about this. I understand the concept that page size (431) should be subtracted from the 743 as those
are pixels I'll not need to scroll to as they are already on my screen.

When I'm scrolling and reach 104, the 2nd column is left-most, when I reach 384 (103 + 280 + 1) then the 3rd column is left-most...but I don't have
room to get to 384 because 743 - 431 = 312 and the scrollbar is at the end.

When I resize the columns so they just fit inside the client area, the scrollbars disappear as they should.

If I mess with the .page and .max relationship then
scrollbars appear when there is no need to scroll.

I also don't understand why if nPage <= nMax a scrollbar appears.

It should be if nPage < nMax a scrollbar appears. You can test this for yourself.

Frustrated.

Help please!
Posted
Updated 5-May-10 5:50am
v3

1 solution

you may follow this

You need to keep track of the last column and row displayed..

and also keep track of current first column and row.

when ever page up is pressed(in VScrollBar) set the current last row as first current row of the grid.

similar for the HScrollbar

Thank you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900