Skip to content

Add Method

Description

Adds a ListViewItem object to a ListViewItems collection in a ListView control and returns a reference to the newly created object.

Syntax

Public Function Add( _
    Optional ByVal [Index](#) As Variant, _
    Optional ByVal [Key](#) As Variant, _
    Optional ByVal [Text](#) As Variant, _
    Optional ByVal [Icon](#) As Variant _
) As [ListViewItem](XtremeSuiteControls~ListViewItem.md)

Parameters

  • Index: An integer specifying the position where you want to insert the ListViewItem. If no index is specified, the ListViewItem is added to the end of the ListViewItems collection.
  • Key: A unique string expression that can be used to access a member of the collection.
  • Text: A string that is associated with the ListViewItem object control.
  • Icon: An integer that sets the icon to be displayed from an ImageList/ImageManager control when the ListView control is set to Icon view.

Remarks

If the list is not currently sorted, a ListViewItem object can be inserted in any position by using the index argument. If the list is sorted, the index argument is ignored and the ListViewItem object is inserted in the appropriate position based upon the sort order.

If the index is not supplied, the ListViewItem object is added with an index that is equal to the number of ListViewItem objects in the collection + 1.

Use the Key property to reference a member of the ListViewItems collection if you expect the value of an object's Index property to change, such as by dynamically adding or removing objects from the collection.

See Also

ListViewItems Collection


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.