ListBox.AddItem Method (Outlook Forms Script)

For a single-column ListBox, the AddItem method adds an item to the list. For a multicolumn ListBox, this method adds a row to the list.

Syntax

expression .AddItem(pvargItem, pvargIndex)

expression A variable that represents a ListBox object.

Parameters

Name

Required/Optional

Data Type

Description

pvargItem

Optional

Variant

Specifies the item or row to add. The number of the first item or row is 0; the number of the second item or row is 1, and so on.

pvargIndex

Optional

Variant

Integer specifying the position within the object where the new item or row is placed.

Remarks

If you supply a valid value for varIndex, the AddItem method places the item or row at that position within the list. If you omit varIndex, the method adds the item or row at the end of the list.

The value of varIndex must not be greater than the value of the ListCount property.

For a multicolumn ListBox, AddItem inserts an entire row, that is, it inserts an item for each column of the control. To assign values to an item beyond the first column, use the List or Column property and specify the row and column of the item.

If the control is bound to data, the AddItem method fails.

You can add more than one row at a time to a ListBox by using List.