Page 1 of 1

[SOLVED] Move to line position in a listiconGadget?

Posted: Sat Sep 20, 2025 10:43 pm
by Randy Walker
I found this and works great for for EditorGadget:
viewtopic.php?p=441542#p441542
and tried to adapt it to ListIconGadget but could not make it work. How do I jump to a particlar line? Here I just want to jump to end of the list:

Code: Select all

  If OpenWindow(0, 0, 0, 230, 120, "Eventtypes example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
     ListIconGadget(1, 10, 10, 150, 100, "ListIcon", 140, #PB_ListIcon_GridLines) 
     For a = 1 To 14 
       AddGadgetItem(1, -1, "Line "+Str(a)) 
     Next
     ;How do I jump to line #14, end of the list ?
     Repeat
       Event = WaitWindowEvent()
     Until Event = #PB_Event_CloseWindow
  EndIf
Would be really nice to know how to jump to any line too.
Thanks!!

Re: Move to line position in a listiconGadget?

Posted: Sat Sep 20, 2025 10:56 pm
by RASHAD
Hi Randy
Using native commands

Code: Select all

Procedure SelectItem(gadget,item)
  SetGadgetState(gadget,item)
  SetGadgetItemState(gadget,item,1)
  SetActiveGadget(gadget)
EndProcedure

If OpenWindow(0, 0, 0, 300, 300, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 10,10, 280, 200, "Name", 200, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
  
  For i = 0 To 1000
    AddGadgetItem(0, -1, Str(i))
  Next
   
  SelectItem(0,150)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
        
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0

        EndSelect
    EndSelect
  Until Quit = 1            
EndIf
For Windows

Code: Select all

Procedure SelectRow(gadget,index)
  Row_H = SendMessage_(GadgetID(gadget), #LVM_GETITEMSPACING, 1, 0) >> 16 
  SendMessage_(GadgetID(0), #LVM_SCROLL, 0,-CountGadgetItems(gadget)*Row_H)  
  SetGadgetItemState(gadget,index,#PB_ListIcon_Selected)
  SetFocus_(GadgetID(gadget))
  SendMessage_(GadgetID(0), #LVM_SCROLL, 0,index*Row_H)
EndProcedure

LoadFont(0,"Arial",12)
If OpenWindow(0, 0, 0, 640, 350, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0,  10,  10, 620, 280, "Column 0", 400,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
  SetGadgetFont(0,FontID(0))
  AddGadgetColumn(0, 1, "Column 1" , 200)
  For x = 0 To 100
    AddGadgetItem(0, x, "Item "+Str(x)+Chr(10)+"Item "+Str(x))
  Next    
EndIf
SelectRow(0,80)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
      EndSelect
  EndSelect
  
Until Quit = 1

Re: Move to line position in a listiconGadget?

Posted: Sun Sep 21, 2025 12:08 am
by Randy Walker
PERFECT! Once again, You are the man RASHAD. THANKS!!!! ! ! !

Re: [SOLVED] Move to line position in a listiconGadget?

Posted: Wed Sep 24, 2025 3:10 pm
by Axolotl
Windows only:

Code: Select all

SendMessage_(GadgetID(Gadget), #LVM_ENSUREVISIBLE, Index, #False) ; lParam ==> #True if partially visible is okay.