ListItem(s)

Description

The ListItems collection contains one or more ListItem objects.

A ListItem consists of text, the index of an associated icon (ListImage object), and, in Report view, an array of strings representing subitems.

ListItem objects can contain both text and pictures. However, to use pictures, you must reference an ImageList control using the Icons and SmallIcons properties.
You can also change the image by using the Icon or SmallIcon property.

ListItems Collection Properties and Methods

Property

Description

Count

(read-only) The total number of ListItems in the collection

Item (index)

Returns a specific member of the collection (either by position or by key).

Because Item is the default property, the following lines are equivalent :
Print MyCollection(1)
Print MyCollection.Item(1)

Method

Description

Add

Parameters: [Index], [Key], [Text], [Icon], [SmallIcon]

Adds a ListItem to a ListItem s collection in a ListView control

Index

(optional) An integer specifying the position where you want to insert the ListItem. If not specified, the ListItem is added to the end of the ListItems collection.

Key

(optional) A unique string that can be used to access a specific member of the ListItems collection.

Text

(optional) A string that is associated with the ListItem

Icon

(optional) An integer that sets the icon to be displayed from an ImageList control, when the ListView control is set to Icon view

SmallIcon

(optional) An integer that sets the icon to be displayed from an ImageList control, when the ListView control is set to SmallIcon view

Clear

Removes all ListItems in the collection

Remove (Index)

Parameters: Index

Removes a specific ListItem. Index is an integer or string that uniquely identifies the ListItem. Use an integer to specify the value of the Index property; use a string to specify the value of the Key property.

Individual ListItem Properties and Methods

Property

Description

Checked

(boolean) This property is only useful if the CheckBoxes property of the ListView control the item is contained in is set to True. You can use this property to determine if the item has been checked

Ghosted

(boolean) Determines whether a ListItem is unavailable (appears dimmed)

Icon

Returns or sets the index or key value of an icon in an associated ImageList control. Before you can use an icon in a ListItem, you must associate an ImageList control with the ListViewcontaining the object.
See the Icons property of the ListView Control for more information

Index

(read-only) An integer that uniquely identifies a ListItem in the collection. The index is set by default to the order of the creation of objects in a collection. The index for the first object in a collection will always be 1

Key

A string that uniquely identifies a ListItem in the collection

ListSubItems

Returns a reference to the ListSubItems collection of ListSubItem objects

Selected

(boolean) Determines if the ListItem is selected. This property does not set the SelectedItem property of the ListView control and thus does not cause the object to be selected. It only returns a value indicating whether the ListItem has already been selected by other means. In the ListView control, the SelectedItem property always refers to the first selected item. Therefore, if multiple items are selected, you must iterate through all of the items, checking each item's Selected property

SmallIcon

Returns or sets the index or key value of a smallicon in an associated ImageList control. Before you can use an licon in a ListItem, you must associate an ImageList control with the ListViewcontaining the object.
See the SmallIcons property of the ListView Control for more information

SubItems (index)

Returns or sets an array of strings (a SubItem) representing the ListItem's data (in Report view). A ListItem can have any number of associated data strings (SubItems) but each ListItem must have the same number of SubItems. It is recommended that new applications use the ListSubItems collection (see above) because of it's increased flexibility

Text

Returns or sets the text contained in the ListItem object

ToolTipText

Returns or sets a ToolTip

Method

Description

EnsureVisible

(boolean) Ensures a specific ListItem is visible by scrolling the ListView