Thread: GTListView
View Single Post
Old 18 February 2021, 13:27   #2
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 5,260
Here's a working example, but bear in mind that you need to do a GTChangeList command to detach and reattach the list to the listview whenever you change the list, otherwise bad things will happen. Also, this is AmiBlitz3 code, if you're compiling under Blitz 2.1, I think you need to set a finite limit on the size of a List array, which limits how many entries you can display.

Code:
WbToScreen 0

NEWTYPE .listitem
  dummy.w
  itemname.s
End NEWTYPE

Dim List MyListItems.listitem(0)

For i.w = 1 To 50
  If AddItem(MyListItems())
    MyListItems()\itemname = "Entry " + Str$(i)
  End If
Next i

GTNewLookProp On ; Gives the nicer looking sliders

GTTags #GTLV_ShowSelected, 0 ; Leaves the selected bar on the last clicked entry

GTListView 0, 0, 10, 10, 150, 150, "List Options", #PLACETEXT_BELOW, MyListItems()


Window 0, 200, 200, 200, 200, #WFLG_DRAGBAR|#WFLG_CLOSEGADGET|#WFLG_DEPTHGADGET, "Test", 0, 1

AttachGTList 0, 0

DefaultOutput

Repeat
  ev.l = WaitEvent
  If ev
    NPrint "Event: ", Hex$(ev)
    If ev = #IDCMP_GADGETUP
      If GadgetHit = 0
        NPrint "Listview hit: ", EventCode
      End If
    End If
  End If
Until ev = #IDCMP_CLOSEWINDOW

End
Where did you find the example you tried? Curious what might be wrong with it...
Daedalus is offline  
 
Page generated in 0.05274 seconds with 11 queries