ListIconGadget()

Syntax

Result = ListIconGadget(#Gadget, x, y, Width, Height, Title$, TitleWidth [, Flags])
Description
Creates a ListIcon gadget in the current GadgetList.

Parameters

#Gadget A number to identify the new gadget. #PB_Any can be used to auto-generate this number.
x, y, Width, Height The position and dimensions of the new gadget.
Title$ The title for the first column in the gadget. The gadget is created with one initial column.
TitleWidth The width of the first column in the gadget.
Flags (optional) Flags to modify the gadget behavior. It can be a combination of the following values:
  #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      : No effect (for PureBasic source compatibility only). 
  #PB_ListIcon_AlwaysShowSelection: No effect (for PureBasic source compatibility only).

Return value

Returns nonzero on success and zero on failure. If #PB_Any was used as the #Gadget parameter then the return-value is the auto-generated gadget number on success.

Remarks

A 'mini help' can be added to this gadget using GadgetToolTip().

The following functions can be used to act on the list content:

- AddGadgetColumn(): Add a column to the gadget.
- RemoveGadgetColumn(): Remove a column from the gadget.
- AddGadgetItem(): Add an item (with an optional image in the standard 16x16 icon size).
- RemoveGadgetItem(): Remove an item.
- ClearGadgetItems(): Remove all the items.
- CountGadgetItems(): Returns the number of items currently in the #Gadget.

- 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). Like with AddGadgetItem(), it is possible to set the text for several columns at once, with the Chr(10) separator.
- SetGadgetItemImage(): Changes the current image of the specified item.
- 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.
This gadget supports the SetGadgetColor() and GetGadgetColor() functions 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

 If OpenWindow(0, 100, 100, 300, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   ListIconGadget(0, 5, 5, 290, 90, "Name", 100)
   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 SpiderBasic Road, BigTown, CodeCity")
 EndIf

Example

  ; Shows possible flags of ListIconGadget in action...
  If OpenWindow(0, 0, 0, 640, 450, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ; left column
    TextGadget    (#PB_Any,  10,  10, 300, 20, "ListIcon Standard", #PB_Text_Center)
    ListIconGadget(0,  10,  25, 300, 120, "Column 1", 100)
    TextGadget    (#PB_Any,  10, 155, 300, 20, "ListIcon with Checkbox", #PB_Text_Center)
    ListIconGadget(1,  10, 170, 300, 120, "Column 1", 100, #PB_ListIcon_CheckBoxes)  ; ListIcon with checkbox
    TextGadget    (#PB_Any,  10, 300, 300, 20, "ListIcon with Multi-Selection", #PB_Text_Center)
    ListIconGadget(2,  10, 315, 300, 120, "Column 1", 100, #PB_ListIcon_MultiSelect) ; ListIcon with multi-selection
    ; right column
    TextGadget    (#PB_Any, 330,  10, 300, 20, "ListIcon with separator lines",#PB_Text_Center)
    ListIconGadget(3, 330,  25, 300, 120, "Column 1", 100, #PB_ListIcon_GridLines)
    For a = 0 To 3            ; add columns to each of the first 4 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
  EndIf

See Also

AddGadgetColumn(), RemoveGadgetColumn(), AddGadgetItem(), RemoveGadgetItem(), ClearGadgetItems(), CountGadgetItems(), GetGadgetState(), SetGadgetState(), GetGadgetAttribute(), SetGadgetAttribute(), GetGadgetItemText(), SetGadgetItemText(), SetGadgetItemImage(), GetGadgetItemState(), SetGadgetItemState(), GetGadgetItemData(), SetGadgetItemData(), GetGadgetItemAttribute(), SetGadgetItemAttribute(), GetGadgetColor(), SetGadgetColor(), ListViewGadget()

Supported OS

All

<- IsGadget() - Gadget Index - ListViewGadget() ->