[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'ComCtrls' (#lcl)

# TListItems.Add

Adds a new list item to the container.

## Declaration

Source position: comctrls.pp line 1165

`public function TListItems.Add: TListItem;`

## Function result

The TListItem instance created and stored in the method.

## Description

Add is a TListItem function used to create a new list item instance and add it to the container. The return value contains the TListItem instance created in the method, and stored in the internal list for the container.

When a list view control has been assigned to Owner, its CreateListItem method is called to create the new list item. A custom item class can be provided using the OnCreateItemClass event handler in the list view control. Otherwise, TListItem.Create is called to create the list item using the container class instance as the Owner.

Add calls the AddItem method to store the new TListItem instance. The widgetset class is notified of the new cached item when its handle is available. The ItemInserted method in Owner is called to execute an overridden InsertItem method (when available) or signal the OnInsert event handler for the list view control (when assigned).

Use Insert to create a new list item and store it at a specified position in the container.

## See also

TListItems.AddItem |  | Adds the specified list item to the storage for the container.
TListItems.Insert |  | Creates and inserts a list item at the specified ordinal position in the container.
TCustomListView.CreateListItem |  | Signals the OnCreateItemClass event handler to get the class type used for new list items, and creates a new list item.
TCustomListView.OnCreateItemClass |  | Event handler signalled to get the class reference used to create new list view items.
TCustomListView.InsertItem |  | Inserts an Item into the List.
TCustomListView.ItemInserted |  | Performs actions when a list item has been inserted in the Items collection.
TCustomListView.OnInsert |  | Event handler signalled when a list item is added to or inserted in the Items for the control.