Restored from previous forum. Originally posted by TerryHough.
Thanks Danilo
You pointed me to a solution to the problem. I was using
SetGadgetState but in this manner since I have no idea how many
items there are:
MoveToEnd = SetGadgetState(1, CountGadgetItems(1))
But see you example modifed on one line
Code: Select all
OpenWindow(1,10,10,300,300,#PB_Window_SystemMenu,"ListView Test")
CreateGadgetList(WindowID())
ListViewGadget(1,0,0,300,300)
For a = 0 To 2000
AddGadgetItem(1,-1,"ListView Entry "+Str(a))
Next a
; see this line --------------------------------------
MoveToEnd = SetGadgetState(1, CountGadgetItems(1) - 1)
Repeat
Until WaitWindowEvent() = #PB_EventCloseWindow
This works successfully.
I had expected the CountGadgetItems to return the index of
the last item. See the help description below:
Syntax
Result = CountGadgetItems(#Gadget)
Description
Returns the number of items in the specified #Gadget. The first item index is starting from 1. If the #Gadget doesn't contain any items, 0 is returned.
Apparently, it returns the number of the next available item. Or I just
don't read it correctly.
Your code worked because you actually wrote 2001 items and then set the gadget
state on 2000. But it made me think and reach a solution. Thanks for your
help.
Unfortunately, this is a cludge. I was hoping there is a "flag" to set
that causes the ListViewGadget to automatically scroll. I know very little
about the API, but have worked with other languages where this was an option
for a ListView.
Fred? Maybe you can enlighten me.
Thanks for your help.
Terry