In the ListIconGadget() documentation, it is written:
- "SetGadgetItemText(): Changes the current text of the specified item. (or column header, if item = -1). Like with AddGadgetItem(), it is possible to set the text for several columns at once, with the Chr(10) separator."
It is shown in the example below, where I wonder if I wrote wrong code.
This code displays a table of 3 lines. When clicking on the "Modify line 2" button, the values in the line 2 change: A4 B4 C4, then A8 B8 C8 then A12 B12 C12, etc...
It works with the modify_line_alternative(1) procedure. It does not work with the modify_line(1) where SetGadgetItemText() is used in the same way as AddGadgetItem() written in Open_window().
You can choose modify_line_alternative(1) procedure or modify_line(1) procedure by setting a ";" just before.
Thanks for your help if I wrote wrong code.
Code: Select all
EnableExplicit
Enumeration
#zero
#window
#list_icon_gadget
#button_gadget
EndEnumeration
Procedure.s load_line(Pline.i)
Define wlig$
wlig$ = "A"+Str(Pline) + #LF$ + "B"+Str(Pline) + #LF$ + "C"+Str(Pline)
ProcedureReturn wlig$
EndProcedure
Procedure Open_window()
Define wline.i, wlig$
If OpenWindow(#window,150,150,600,600,"Test SetGadgetItemText")
ListIconGadget(#list_icon_gadget, 10, 10, 310, 100, "Column 1", 100)
AddGadgetColumn(#list_icon_gadget, 1, "Column 2", 100)
AddGadgetColumn(#list_icon_gadget, 2, "Column 3", 100)
For wline = 0 To 2
wlig$ = load_line(wline)
AddGadgetItem(#list_icon_gadget,wline,wlig$)
Next
ButtonGadget(#button_gadget,400,10,150,30,"Modify line 2")
EndIf
EndProcedure
Procedure modify_line(Pline.i)
Define wlig$
Static Sline.i
Sline + 4
wlig$ = load_line(Sline)
SetGadgetItemText(#list_icon_gadget,Pline,wlig$)
EndProcedure
Procedure modify_line_alternative(Pline.i)
Define wlig$
Static Sline.i
Sline + 4
wlig$ = load_line(Sline)
SetGadgetItemText(#list_icon_gadget,Pline,"A"+Str(Sline),0)
SetGadgetItemText(#list_icon_gadget,Pline,"B"+Str(Sline),1)
SetGadgetItemText(#list_icon_gadget,Pline,"C"+Str(Sline),2)
EndProcedure
Procedure ctl_window ()
Define wEvent.i, wEvent_gadget.i
Repeat
wEvent = WaitWindowEvent()
Select wEvent
Case #PB_Event_Gadget
wEvent_gadget = EventGadget()
Select wEvent_gadget
Case #button_gadget
modify_line(1)
; modify_line_alternative(1)
EndSelect
EndSelect
Until wEvent = #PB_Event_CloseWindow
EndProcedure
;- BEGIN
If #LF$ <> Chr(10) ; just to be sure...
End
EndIf
open_window()
ctl_window()
End