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

# TCustomListBox.AddItem

Adds an item to the list.

## Declaration

Source position: stdctrls.pp line 614

`public procedure TCustomListBox.AddItem(`
`const Item: string;`
`AnObject: TObject`
`);`

## Arguments

`Item` |  | The item text.
`AnObject` |  | The associated object, or Nil when not used.

## Description

AddItem is a method used to add a string (and an optional associated object) to the Items for the control. AddItem calls the AddObject method in Items using Item and AnObject as arguments.

Item contains the string value added to the Items in the control.

AnObject is an optional object instance associated with the item, and contains Nil when an object instance has not been assigned. The object can be retrieved using the Items.Objects property for the ItemIndex, and must be cast to the required class type to access values in the object instance.

## See also

TCustomListBox.Items |  | The list of all items defined in the control.