---
title: "getListBoxItem"
canonical: "https://help.vicon.com/space/ShogunPost120/1043038728/getListBoxItem"
format: markdown
---
# Description

Gets the string of an item in the list box user control specified by `userControlID`. If an invalid index is specified, the command will fail.

## Functional area

User Window

# Command syntax

## Syntax

|  |
| --- |
| `getListBoxItem userControlID itemIndex` |

### Arguments

| Name | Type | Required | Comments |
| --- | --- | --- | --- |
| `index` | int | yes | Index of the list box item to get. |
| `userControlId` | int | yes | ID of user control to operate on. |

### Flags

None

## Return value

string

> Macro (scroll-pagebreak)

## Examples

```plaintext
// Get the string of an item in the List Box User Control
int $windowId;
int $controlId; 
int $i, $numItems;
string $itemStr;
 
// First create a User Window to place the Control on
$windowId = `createWindow "MyWindow"`; 
// Create the User Control on the Window. 
$controlId = `createListBox $windowId`;
// Add some items to the List Box.
addListBoxItem $controlId "Item 1";
addListBoxItem $controlId "Item 2";
addListBoxItem $controlId "Item 3";
 
// Get the number of items.
$numItems = `getNumListBoxItems $controlId`;
 
// Iterate through the list of items.
for( $i = 0; 
     $i < $numItems; 
     $i += 1 )
 { 
   $itemStr = `getListBoxItem $controlId $i`; 
   print $itemStr;
 }
```

# Additional information

## Related commands

- [addListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043038522)
- [createListBox](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043039574)
- [deleteAllListBoxItems](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043038472)
- [deleteListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043038890)
- [findListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043038899)
- [getListBoxSelItems](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043039675)
- [getNumListBoxItems](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043039605)
- [selectListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043039785)
- [setListBoxHandler](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost120/pages/1043039834)