SubItems, AllText Property

Purpose

Returns or sets an array of strings (a subitem) representing the ListItem object's data in a ListView control.

Syntax

ListItem.SubItems(index%) [= string]

ListItem.AllText [= string]

Description

The index% parameter identifies a subitem for the specified ListItem.

Subitems are arrays of strings representing the ListItem object's data that are displayed in Report view. For example, you could show the file size and the date last modified for a file.

A ListItem object can have any number of associated item data strings (subitems) but each ListItem object must have the same number of subitems.

There are corresponding column headers defined for each subitem.

You cannot add elements directly to the subitems array. Use the Add method of the ColumnHeaders collection to add subitems.

AllText returns or sets the text for all subitems of a ListItem. The text for each subitem is to be separated by a semicolon.

Example

Global a$, n As Int32

Ocx ListView lv = "", 10, 10, 400, 200 : .View = 3 : .FullRowSelect = True : .GridLines = True

For n = 1 To 4 : lv.ColumnHeaders.Add , , "Column" & n : lv.ColumnHeaders(n).Alignment = 2 : Trace lv.ColumnHeaders(n).SubItemIndex : Next n

For n = 1 To 4

lv.Add , , ""

a$ = Rand(10) & ";" & Rand(10) & ";" & Rand(10) & ";" & Rand(10)

lv(n).AllText = a$

Next n

Do : Sleep : Until Me Is Nothing

 

Sub lv_ColumnClick(ColumnHeader As ColumnHeader)

Local chi As Int = ColumnHeader.Index - 1, li As ListItem

If lv.SelectedCount <> 0

Set li = lv.SelectedItem

Message "Contents of Column" & (chi + 1) & " and Row" & li.Index & #13#10 & "is " & li.SubItems(chi)

Else

Message "Select a row first"

EndIf

EndSub

See Also

ListItem, ColumnHeaders, ListView

{Created by Sjouke Hamstra; Last updated: 23/10/2014 by James Gaite}