Hi
I have a desktop listbox. The user can repeatedly select rows for updates. To make things easier if the visible bottom row is selected the listbox will automatically scroll so that the row is in the middle of the display. The Xojo behaviour seems odd, or maybe it’s just me.
// The selected row is the bottom of the window, move it up.
var noRows as Integer = (me.Height - me.HeaderHeight) \ me.RowHeight
var i as Integer = me.ScrollPosition + (noRows - 1) mod me.SelectedRowIndex
var i1 as Integer = me.ScrollPosition + (noRows - 1)
if me.ScrollPosition + (noRows - 1) mod me.SelectedRowIndex = 0 then
me.ScrollPosition = me.ScrollPosition + (noRows \ 2) + 2
end if
This is the code I’m using (doesn’t really work, but stay with me).
The first VAR statement is calculating the number of visible rows in the listbox. The other 2 are for debugging.
In this case noRows evaluates to 9, therefore SelectedRowIndex is 8, As you can see the second VAR is the calculation to identify the bottom row. For the first page this code works. However if I remove the braces around (noRows - 1) it doesn’t work. It still evaluates to 8 but the IF statement comes out false and resetting scroll position doesn’t run. With the braces that works.
On the second page, noRows is still 9, SelectedRowIndex is 14, the second VAR sets i to 14 but the IF statement fails.
Can anyone explain what is happening here, or where my logic is wrong, and if that is the case how do I do what I want.
Exasperated.
Thanks
1 post - 1 participant