ListViewGadget()

Syntax

Result = ListViewGadget(#Gadget, x, y, Width, Height [, Flags])
Description
Creates a ListView 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. Once a ListView is created, its list of items is empty.

'Flags' are always optional and can be composed of one of the following constants:
  #PB_ListView_Multiselect: allows multiple items to be selected
  #PB_ListView_ClickSelect: allows multiple items to be selected. clicking on one item selects/deselects it
You can add a 'mini help' to this gadget by using GadgetToolTip().

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

- AddGadgetItem(): Add an item.
- RemoveGadgetItem(): Remove an item.
- ClearGadgetItemList(): Remove all the items
- CountGadgetItems(): Returns the number of items currently in the #Gadget.

- GetGadgetItemData(): Get the value that was stored with the gadget item.
- GetGadgetItemState(): Returns nonzero if the item is selected, zero otherwise.
- GetGadgetItemText(): Get the content of the given item.
- GetGadgetState(): Get the index of the selected item or -1 if there is no selected item.
- GetGadgetText(): Get the content of the selected item.
- SetGadgetItemData(): store a value with the given item.
- SetGadgetItemState(): Selects or deselects the given item.
- SetGadgetItemText(): Set the text of the given item.
- SetGadgetState(): Change the selected item. If -1 is specified, the selection will be removed.
- SetGadgetText(): Selects the item with the given text (the text must match exactly).

This gadget supports the SetGadgetColor() and GetGadgetColor() commands with the following values as 'ColorType':
  #PB_Gadget_FrontColor: Textcolor 
  #PB_Gadget_BackColor : Backgroundcolor
The following events are supported through EventType():
  #PB_EventType_LeftClick
  #PB_EventType_LeftDoubleClick
Example:
  If OpenWindow(0, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
    ListViewGadget(0, 10, 10, 250, 120)
    For a = 1 To 12
      AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview") ; define listview content
    Next
    SetGadgetState(0, 9) ; set (beginning with 0) the tenth item as the active one
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Supported OS

All

<- ListIconGadget() - Gadget Index - MDIGadget() ->