ListIconGadget()
Syntax
Result = ListIconGadget(#Gadget, x, y, Width, Height, Title$, TitleWidth [, Flags])Description
Creates a ListIcon gadget in the current GadgetList. If #PB_Any is used as '#Gadget' parameter, the new gadget number will be returned as 'Result'. #Gadget will be the number returned by the EventGadget() command. 'Title$' is the first column title, and 'TitleWidth' its initial width (in pixels). Once a ListIconGadget is created, its list of items is empty.
You can add a 'mini help' to this gadget by using GadgetToolTip().
The following commands can be used to act on the list content:
- AddGadgetColumn(): Add a column to the gadget.
- AddGadgetItem(): Add an item (with an optional image in the standard 16x16 icon size).
- RemoveGadgetItem(): Remove an item.
- ClearGadgetItemList(): Remove all the items.
- CountGadgetItems(): Returns the number of items currently in the #Gadget.
- GetGadgetItemColor(): Returns front or backcolor of the item.
- SetGadgetItemColor(): Changes front or backcolor of the item.
- GetGadgetItemData(): Returns the value that was stored with item.
- SetGadgetItemData(): Stores a value with the item.
- GetGadgetItemState(): Returns the current state of the specified item.
- SetGadgetItemState(): Changes the current state of the specified item.
- GetGadgetItemText(): Returns the current text of the specified item. (or column header, if item = -1)
- SetGadgetItemText(): Changes the current text of the specified item. (or column header, if item = -1)
- GetGadgetState(): Returns the first selected item or -1 if there is no item selected.
- SetGadgetState(): Change the selected item (all other selected items will be deselected). If -1 is specified, no more item will be selected.
- GetGadgetItemAttribute() / SetGadgetItemAttribute(): With the following attribute:#PB_ListIcon_ColumnWidth : Returns/Changes the width of the given 'Column'. The 'Item' parameter is ignored.
If you want to add content to ListIcons with several columns using AddGadgetItem(), you should use the format "first column"+Chr(10)+"second one" as Text$ parameter. See also the following example.
Use ChangeListIconGadgetDisplay() to change the aspect of the ListIcon, as four forms are supported (large icon, small icon, list and report).
'Flags' are always optional and can be composed of one of the following constants:#PB_ListIcon_CheckBoxes : Display checkboxes in the first column. #PB_ListIcon_MultiSelect : Enable multiple selection. #PB_ListIcon_GridLines : Display separator lines between rows and columns. #PB_ListIcon_FullRowSelect : The selection covers the full row instead of the first column. #PB_ListIcon_HeaderDragDrop : The order of columns can be changed using drag'n'drop. #PB_ListIcon_AlwaysShowSelection: The selection is still visible, even when the gadget is not activated.This gadget supports the SetGadgetColor() and GetGadgetColor() commands with the following values as 'ColorType':#PB_Gadget_FrontColor: Textcolor #PB_Gadget_BackColor : Backgroundcolor #PB_Gadget_LineColor : Color for the gridlines if the #PB_ListIcon_GridLines flag is used.The following events are supported through EventType():#PB_EventType_LeftClick: left click on an item, or a checkbox was checked/unchecked #PB_EventType_LeftDoubleClick #PB_EventType_RightClick #PB_EventType_RightDoubleClick #PB_EventType_Change: the current item changed
Example 1:If OpenWindow(0, 100, 100, 300, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) If CreateGadgetList(WindowID(0)) ListIconGadget(0, 5, 5, 290, 90, "Name", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection) AddGadgetColumn(0, 1, "Address", 250) AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay") AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity") Repeat Event = WaitWindowEvent() Until Event = #PB_Event_CloseWindow EndIf EndIfExample 2:; Shows possible flags of ListIconGadget in action... If OpenWindow(0, 0, 0, 640, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) ; left column TextGadget (6, 10, 10, 300, 20, "ListIcon Standard", #PB_Text_Center) ListIconGadget(0, 10, 25, 300, 70, "Column 1", 100) TextGadget (7, 10, 105, 300, 20, "ListIcon with Checkbox", #PB_Text_Center) ListIconGadget(1, 10, 120, 300, 70, "Column 1", 100, #PB_ListIcon_CheckBoxes) ; ListIcon with checkbox TextGadget (8, 10, 200, 300, 20, "ListIcon with Multi-Selection", #PB_Text_Center) ListIconGadget(2, 10, 215, 300, 70, "Column 1", 100, #PB_ListIcon_MultiSelect) ; ListIcon with multi-selection ; right column TextGadget (9, 330, 10, 300, 20, "ListIcon with separator lines",#PB_Text_Center) ListIconGadget(3, 330, 25, 300, 70, "Column 1", 100, #PB_ListIcon_GridLines) TextGadget (10, 330, 105, 300, 20, "ListIcon with FullRowSelect and AlwaysShowSelection",#PB_Text_Center) ListIconGadget(4, 330, 120, 300, 70, "Column 1", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection) TextGadget (11, 330, 200, 300, 20, "ListIcon Standard with large icons",#PB_Text_Center) ListIconGadget(5, 330, 220, 300, 65, "", 200,#PB_ListIcon_GridLines) For a = 0 To 4 ; add columns to each of the first 5 listicons For b = 2 To 4 ; add 3 more columns to each listicon AddGadgetColumn(a, b, "Column " + Str(b), 65) Next For b = 0 To 2 ; add 4 items to each line of the listicons AddGadgetItem(a, b, "Item 1"+Chr(10)+"Item 2"+Chr(10)+"Item 3"+Chr(10)+"Item 4") Next Next ; Here we change the ListIcon display to large icons and show an image If LoadImage(0, "map2.bmp") ; change path/filename to your own 32x32 pixel image ChangeListIconGadgetDisplay(5, 0) AddGadgetItem(5, 1, "Picture 1", ImageID(0)) AddGadgetItem(5, 2, "Picture 2", ImageID(0)) EndIf Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow EndIf
Supported OS
All