Clear ListIconGadget and lose icon column

Just starting out? Need help? Post your questions and find answers here.
BarryG
Addict
Addict
Posts: 4130
Joined: Thu Apr 18, 2019 8:17 am

Clear ListIconGadget and lose icon column

Post by BarryG »

Is there a way to clear a ListIconGadget to remove the icon column on its far-left, without the overhead of freeing and recreating it from scratch? See in the example below, after clearing it, there is still a gap for the icons (in red). I want to lose that gap without creating a new ListIconGadget, because the ListIconGadget specs are read from a file and/or remote network location, which can be slow. Thanks.

Image

Code: Select all

Global icon = LoadImage(0, #PB_Compiler_Home + "Examples\Sources\Data\CdPlayer.ico")

Procedure PopulateListIcon()
  ClearGadgetItems(0)
  AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay", icon)
  AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity", icon)
EndProcedure

OpenWindow(0, 100, 100, 300, 140, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListIconGadget(0, 5, 5, 290, 90, "Name", 150, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(0, 1, "Address", 250)
PopulateListIcon()

ButtonGadget(1, 5, 100, 290, 30, "Click to refresh ListIconGadget without icons")

Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_Gadget And EventGadget() = 1
    icon = 0 ; We want no icons this time.
    PopulateListIcon()
  EndIf
Until Event = #PB_Event_CloseWindow
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Clear ListIconGadget and lose icon column

Post by RASHAD »

Hi BarryG

Code: Select all

Global icon = LoadImage(0, #PB_Compiler_Home + "Examples\Sources\Data\CdPlayer.ico")

Procedure PopulateListIcon()
  ClearGadgetItems(0)
  For i = 0 To 100
    AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay", icon)
    AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity", icon)
  Next
EndProcedure

OpenWindow(0, 100, 100, 300, 800, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListIconGadget(0, 5, 5, 290, 700, "Name", 150, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(0, 1, "Address", 250)
PopulateListIcon()

ButtonGadget(1, 5, 750, 290, 30, "Click to refresh ListIconGadget without icons")

Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_Gadget And EventGadget() = 1
      himlIcons = SendMessage_(GadgetID(0), #LVM_GETIMAGELIST, #LVSIL_SMALL, 0)
      ImageList_SetIconSize_(himlIcons,1,16)
      SendMessage_(GadgetID(0),#LVM_SETIMAGELIST,#LVSIL_SMALL,himlIcons)
    ;PopulateListIcon()
  EndIf
Until Event = #PB_Event_CloseWindow
Egypt my love
BarryG
Addict
Addict
Posts: 4130
Joined: Thu Apr 18, 2019 8:17 am

Re: Clear ListIconGadget and lose icon column

Post by BarryG »

You da man, Rashad! Thanks so much.
Post Reply