---
title: "selectListBoxItem"
canonical: "https://help.vicon.com/space/Shogun112/31236289/selectListBoxItem"
format: markdown
---
# Description

Selects an item in the list box user control that is specified by userControlId. Selected items appear highlighted in the list.

If the `-multi` flag was specified with the [createListBox](https://vicon-help.atlassian.net/wiki/spaces/Shogun112/pages/31231725) command, this command adds to the current list box selection. Otherwise, the command replaces the current selection.

To remove selection, pass a `-1` as the index argument.

## Functional area

User Window

# Command syntax

## Syntax

|  |
| --- |
| `selectListBoxItem userControlID index` |

### Arguments

| **Name** | **Type** | **Required** | **Comments** |
| --- | --- | --- | --- |
| `index` | int | yes | Zero based index of the item to select. |
| `userControlId` | int | yes | ID of user control to operate on. |

### Flags

None

> Macro (scroll-pagebreak)

## Return value

integer

## Examples

```plaintext
// Select an item in a List Box User Control.
int $windowId;
int $controlId;
int $index;
 
// 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";
$index = `addListBoxItem $controlId "Item 2"`;
addListBoxItem $controlId "Item 3";
 
// Select the item whose index we just got.
selectListBoxItem $controlId $index;
```

# Additional information

## Related commands

- [addListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/Shogun112/pages/31238029)
- [createListBox](https://vicon-help.atlassian.net/wiki/spaces/Shogun112/pages/31231725)
- [deleteAllListBoxItems](https://vicon-help.atlassian.net/wiki/spaces/Shogun112/pages/31236555)
- [deleteListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/Shogun112/pages/31239293)
- [findListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/Shogun112/pages/31239541)
- [getListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/Shogun112/pages/31236991)
- [getListBoxSelItems](https://vicon-help.atlassian.net/wiki/spaces/Shogun112/pages/31239311)
- [getNumListBoxItems](https://vicon-help.atlassian.net/wiki/spaces/Shogun112/pages/31230824)
- [setListBoxHandler](https://vicon-help.atlassian.net/wiki/spaces/Shogun112/pages/31228570)