---
title: "addListBoxItem"
canonical: "https://help.vicon.com/space/Shogun19/13795752/addListBoxItem"
format: markdown
---
# Description

Adds a string that is specified by `itemString` to the list box user control that is specified by `userControlID`.

Strings are added to the end of the list box, unless the `-insert` flag was provided, in which case, the string is inserted at the index specified. If the `-sort` flag was provided with the [createListBox](https://vicon-help.atlassian.net/wiki/spaces/Shogun19/pages/13795874) command, the strings in the list box will appear in alphabetical order, and the `-insert` flag has no visible effect.

## Functional area

User Window

# Command syntax

## Syntax

|  |
| --- |
| `addListBoxItem userControlID "itemString" [-insert integer]` |

### Arguments

| **Name** | **Type** | **Required** | **Comments** |
| --- | --- | --- | --- |
| `itemString` | string | yes | String to add to the list box. |
| `userControlId` | int | yes | ID of user control to operate on. |

### Flags

| **Name** | **Flag arguments** | **Argument type** | **Exclusive to** | **Comments** |
| --- | --- | --- | --- | --- |
| `insert` | 1 | integer | — | Specifies the zero based index which the string should be inserted. If this flag isn't specified, the item will be appended to the end of the list. |

## Return value

integer

## Examples

```plaintext
// Add items to a List Box User Control.
int $windowId;
int $controlId;
 
// First create a User Window to place the Control on
$windowId = `createWindow "MyWindow"`;
 
// Create the User Control on the Window. Don't use the
// sort flag so we can demonstrate how to insert vs. append.
$controlId = `createListBox $windowId`;
 
// Add some items to the List Box. Insert one as well
addListBoxItem $controlId "Item 1";
addListBoxItem $controlId "Item 2";
addListBoxItem $controlId "Item 3";
addListBoxItem $controlId "Inserted!" -insert 1;
 
// Set the current selection to the first item
selectListBoxItem $controlId 0;
```

# Additional information

## Related commands

- [createListBox](https://vicon-help.atlassian.net/wiki/spaces/Shogun19/pages/13795874)
- [deleteAllListBoxItems](https://vicon-help.atlassian.net/wiki/spaces/Shogun19/pages/13795920)
- [deleteListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/Shogun19/pages/13795934)
- [findListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/Shogun19/pages/13795990)
- [getListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/Shogun19/pages/13796152)
- [getListBoxSelItems](https://vicon-help.atlassian.net/wiki/spaces/Shogun19/pages/13796154)
- [getNumListBoxItems](https://vicon-help.atlassian.net/wiki/spaces/Shogun19/pages/13796188)
- [selectListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/Shogun19/pages/13796510)
- [setListBoxHandler](https://vicon-help.atlassian.net/wiki/spaces/Shogun19/pages/13796606)