However, when a row is selected programmatically, the highlight colour is a faint, dull grey instead. I think it should use #COLOR_HIGHLIGHT. Yes, I can apply the colour myself and keep track of row selections (or just unhighlight the whole list when a different row is selected), but that is a pita if a few cells have their own individual colour.
Is there a really simple way to get PB to use #COLOR_HIGHLIGHT when SetGadgetItemState() is applied?
Code: Select all
Enumeration
#Win
#Panel
#Btn
#List
EndEnumeration
Global iRow.i, iCol.i, iExit.i = #False, iRow05.i = 5
Global sRow.s
Procedure PfSetListRowColours(iList.i, iRowColourEven.i, iRowColourOdd.i)
;#-----------------------------------------------------------------------
Protected iRow.i
Protected iRowIsOdd.i = #False
Protected iTotalRows.i = CountGadgetItems(iList)
For iRow = 0 To (iTotalRows - 1)
If(iRowIsOdd = #True)
SetGadgetItemColor(iList, iRow, #PB_Gadget_BackColor, iRowColourOdd, #PB_All)
iRowIsOdd = #False
Else
SetGadgetItemColor(iList, iRow, #PB_Gadget_BackColor, iRowColourEven, #PB_All)
iRowIsOdd = #True
EndIf
Next iRow
EndProcedure
If OpenWindow(#Win, 0, 0, 530, 300, "ListIcon Highlight Row", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PanelGadget(#Panel, 5, 5, 520, 290)
AddGadgetItem(#Panel, 0, "Tab 00")
ButtonGadget(#Btn, 10, 10, 200, 30, "Select Row 05")
ListIconGadget(#List, 10, 50, 490, 205, "Col 00", 100, #PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_FullRowSelect)
AddGadgetColumn(#List, 1, "Col 01", 100)
AddGadgetColumn(#List, 2, "Col 02", 100)
AddGadgetColumn(#List, 3, "Col 03", 100)
AddGadgetColumn(#List, 4, "Col 04", 100)
For iRow = 0 To 10
sRow = ""
For iCol = 0 To 4
sRow = sRow + "Row" + RSet(Str(iRow),2,"0") + " Col" + RSet(Str(iCol),2,"0") + #LF$
Next
AddGadgetItem(#List, -1, sRow)
Next
PfSetListRowColours(#List, RGB(210,255,255), RGB(175,215,255))
AddGadgetItem(#Panel, 1, "Tab 01")
CloseGadgetList() ;#Panel
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow: iExit = #True
Case #PB_Event_Gadget
Select EventGadget()
Case #Btn
SetGadgetItemState(#List, iRow05, #PB_ListIcon_Selected)
SetActiveGadget(#List) ;<---- Solution!
EndSelect
EndSelect
Until iExit = #True
EndIf
End