Hi
I have created a list box. The list can be scrolled with up/down buttons which works fine. I am adding in a slider bar but having difficulty with the maths.
The list box has the following variables:
lines: number of viewable lines in the list box
itemCount: total number of items in the list (1 based)
firstItem: the first viewable item in the list (this obviously changes as the list scrolls up & down)
So to display the list I am effectively showing items from firstItem to (firstItem + lines - 1).
The slider bar value needs to be within the range 0 to 1 (which is then used to calculate the coords). So, given that I know the above values, how do I calculate the slider position?
I know there is a formula for it, I just can't work it out!
I have created a list box. The list can be scrolled with up/down buttons which works fine. I am adding in a slider bar but having difficulty with the maths.
The list box has the following variables:
lines: number of viewable lines in the list box
itemCount: total number of items in the list (1 based)
firstItem: the first viewable item in the list (this obviously changes as the list scrolls up & down)
So to display the list I am effectively showing items from firstItem to (firstItem + lines - 1).
The slider bar value needs to be within the range 0 to 1 (which is then used to calculate the coords). So, given that I know the above values, how do I calculate the slider position?
I know there is a formula for it, I just can't work it out!