Restored from previous forum. Originally posted by TerryHough.
Can anyone tell me how to get the ListViewGadget to automatically
down to the last item listed?
The vertical scroll bar creates automatically when the box
is filled, but the view remains at the top.
Is there a command to issue to have the ListView automatically scroll?
Thanks,
Terry
Scrolling ListViewGadget
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
Use SetGadgetState():
cya,
...Danilo
(registered PureBasic user)
Use SetGadgetState():
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
SetGadgetState(1,2000)
Repeat
Until WaitWindowEvent() = #PB_EventCloseWindow
...Danilo
(registered PureBasic user)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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
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
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
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
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by TerryHough.
Any pointers on how to get the ListIconGadget to scroll to the
item selected with SetGadgetState?
Thanks in advance,
Terry
This technique doesn't work with the ListIconGadget for me.Originally posted by Danilo
Use SetGadgetState():
cya,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 SetGadgetState(1,2000) Repeat Until WaitWindowEvent() = #PB_EventCloseWindow
...Danilo
(registered PureBasic user)
Any pointers on how to get the ListIconGadget to scroll to the
item selected with SetGadgetState?
Thanks in advance,
Terry
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Paul.
Hey Terry, this works for me...
This example selects item #50 when you press the button.
Hey Terry, this works for me...
Code: Select all
hWnd=OpenWindow(0,10,10,300,200,#PB_Window_SystemMenu,"ListView")
If hWnd=0 Or CreateGadgetList(hWnd)=0:End:EndIf
ButtonGadget(1,230,175,60,20,"Item 50")
LI=ListIconGadget(2,10,10,280,160,"Name",100,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
For tmp=0 To 100
AddGadgetItem(2,tmp,"Test "+Str(tmp))
Next
Repeat
eventid=WaitWindowEvent()
If eventid=#PB_EventGadget
If EventGadgetID()=1
SendMessage_(LI,#LVM_ENSUREVISIBLE,50,0)
SetGadgetState(2,50)
EndIf
EndIf
Until eventid=#PB_Event_CloseWindow
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm