A ListItem consists of text, the index of an associated icon (ListImage object), and, in Report view, an array of strings representing subitems.
A ListItems object is a collection of ListItem objects.
ListView.ListItems
ListView.ListItems[.Item](index)
index:Variant
The syntax above refers to the collection and to individual elements in the collection, respectively, according to the standard collection syntax.
The ListView.ListItems property returns a reference to the ListItems object, a collection of ListItem objects.
ListView.ListItems.Item(index) returns a reference to the ListItem with the given index (integer or string). Since Item is the default property it can be left out.
For each ListItem object, you can add text and pictures. However, to use pictures, you must reference an ImageList control using the Icons and SmallIcons properties of the ListView Ocx.
You can also change the image by using the Icon or SmallIcon properties of the ListItem object.
You can manipulate ListItem objects using standard collection methods (for example, the Add and Remove methods). Each element in the collection can be accessed by its index, the value of the Index property, or by a unique key, the value of the Key property.
The ListItems collection properties and methods:
Add | Clear | Count | Item | Remove
The ListItem properties and methods:
AllText | BackColor | Bold | Checked | CreateDragImage | EnsureVisible | ForeColor | Ghosted | Icon | Index | Italic | Key | ListViewName | Selected | SmallIcon | SubItems | Tag | Text | Underline | Visible
The CreateDragImage is not implemented
Dim li As ListItem
Ocx ListView lv = "", 10, 10, 300, 300 : .View = 3 : .FullRowSelect = True
lv.ColumnHeaders.Add , , "Column1" : lv.ColumnHeaders.Add , , "Column 2"
Local n : For n = 1 To 26 : lv.Add , , ""
Set li = lv.ListItems(n)
li.AllText = "Item" & n & ";" & Chr(64 + n)
If Odd(n) Then li.Bold = True
If n / 3 = Int(n / 3) Then li.ForeColor = RGB(255, 0, 0)
If n / 4 = Int(n / 4) Then li.BackColor = RGB(192, 192, 192)
Next n
Do : Sleep : Until Me Is Nothing
Sub lv_Click
If lv.SelectedCount <> 0
Set li = lv.SelectedItem
Message "Selected Row has the following items:"#13#10 & li.SubItems(0) & #13#10 & li.SubItems(1)
EndIf
EndSub
{Created by Sjouke Hamstra; Last updated: 12/10/2014 by James Gaite}