Add Method - ListItems

Add a List Item to the List Items collection.

object.ListItems.Add(Index , Text, Icon, SmallIcon)

Client support

   Newlook Smartclient only.

Parameters

Index - (Integer, Optional)

Specifies the position within the ListItems collection to create the new object. If this value is zero the item will be added to the start of the list. If a value is specified the new ListItem object will be created at that position and the index of any subsequent items will be incremented by one. The ListItems collection index is a zero based index therefore the first object in the collection will have an index of 0. If no index is specified then the object is added to the start of the collection. Specify app.activeform.object.ListItems.Count as the index to insert the new ListItem as the last object in the collection.

Text - (String, Required)

The string that appears in the ListItem label.

Icon - (Integer, Optional)

The index of an icon in an associated ImageList control. In the ListView control this is the ImageList control assigned to the Icons, StateIcons or SmallIcons properties. If there is no ImageList associated with this control specify an index of 0.

SmallIcon - (Integer, Optional)

The index of an icon in an associated ImageList control. In the ListView control this is the ImageList control assigned to the SmallIcons properties when the view property is set to ViewSmallIcons. If there is no ImageList associated with this control specify an index of 0.

Use

This method allows you to add a ListItem object to the control's ListItems collection dynamically. This method is typically attached to the OnReceive property of the form.

EXAMPLES

The following example adds a new ListItem to the bottom of the first column in a ListView control.

JSCRIPT

function AddItem()

{

   var itemCount = App.ActiveForm.lstTest.ListItems.Count;

   App.ActiveForm.lstTest.ListItems.Add(itemCount,"New Item",0,0);

}

 

VB SCRIPT

Sub AddNewItem

iItemCount = App.Activeform.lstTest.ListItems.Count

App.ActiveForm.lstTest.ListItems.Add iItemCount,"New Item",0,2

End Sub

TIP:

If the Clear method has been called prior to the Add method being evoked it may be necessary to use the RefreshForm method to update the control.  

See Also

RefreshForm Method | Clear Method | Remove Method | Aid Key Constants | AddNew method | AddItem method | AddRecord method | Node object | ListItem object | ColumnHeader object | Add Method - Function Keys | Add Method - Nodes | Add Method - ColumnHeaders | Add Method - Controls

Applies To

ListItems collection


© 2004-2021 looksoftware. All rights reserved.