---
title: "findListBoxItem"
canonical: "https://help.vicon.com/space/ShogunPost121/1253736496/findListBoxItem"
format: markdown
---
# Description

Searches for a string in the list Box user control that is specified by `userControlID`. The search is case-insensitive.

By default, the search begins at the beginning of the list, searching for itemString as an exact match or prefix of any of the list box items.

If the `-start` flag is specified, the search will begin after the index provided, wrapping back to the top of the list, up until the provided index if a match isn't made.

If the `-exact` flag is specified, the search will only be satisfied if a full string match is made. If `itemString` isn't found, then a value of -1 is returned.

## Functional area

User Window

# Command syntax

## Syntax

> Macro (scroll-tablelayout)

|  |
| --- |
| `findListBoxItem userControlID "itemString"[-start integer] [-exact]` |

### Arguments

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

> Macro (scroll-pagebreak)

### Flags

> Macro (scroll-tablelayout)

| Name | Flag arguments | Argument type | Exclusive to | Comments |
| --- | --- | --- | --- | --- |
| `start` | 1 | integer | — | Index of the item to start searching after. By default, the search will begin at the beginning of the list of items. |
| `exact` | 0 | — | — | Performs the search using an exact, case insensitive, string comparison. By default, the search will be satisfied if the search string is a prefix of an item string. |

## Return value

integer

## Examples

```plaintext
// Search for a string 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 "This is text";
addListBoxItem $controlId "This";
addListBoxItem $controlId "is text";
 
// First search for the word "this". It will return
// 0, since "this" is a prefix of the first item. 
$index = `findListBoxItem $controlId "this"`;
print $index;
 
// Now search for "this" again, this time specifying
// the -exact flag. It will return 1 
$index = `findListBoxItem $controlId "this" -exact`;
print $index;
```

# Additional information

## Related commands

- [addListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737108)
- [createListBox](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738733)
- [deleteAllListBoxItems](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736453)
- [deleteListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736724)
- [getListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736807)
- [getListBoxSelItems](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737388)
- [getNumListBoxItems](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737357)
- [selectListBoxItem](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736476)
- [setListBoxHandler](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738430)