AddListItem Method

Adds a new item to a ComboBox or ListBox control, optionally making it possible for you to specify the item's item ID.

Control.AddListItem(cItem [, nItemID] [, nColumn])

Parameters

  • cItem
    Specifies the item to add to the control.

  • nItemID
    Specifies an integer representing the unique ID of the item in the control. The maximum value you can specify for nItemID is 32,767.

    If you omit nItemID and the Sorted property is set to True (.T.), cItem is added in alphabetic sort order. If you omit nItemID and the Sorted property is set to False (.F.), cItem is added to the end of the list of the ComboBox or ListBox.

  • nColumn
    Specifies the column of the control to add the new item to. The default is 1.

Remarks

Use the AddItem method or AddListItem method when the RowSourceType property is set to 0 (None).

Each item added to a ComboBox or ListBox has two identification numbers assigned to it:

  • nItemID, an integer corresponding to the unique ID of the item in the control: the first item corresponds to nItemID = 1 unless another nItemID is specified.
  • nIndex, an integer corresponding to the order in which items are displayed by the control: the first item in the control corresponds to nIndex = 1.

See Also

AddItem Method | Clear Method | ListIndex Property | ListItemID Property | RowSourceType Property | RemoveItem Method | Sorted Property

Applies To: ComboBox Control | ListBox Control