/
findListBoxItem
findListBoxItem
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
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. |
Flags
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
// 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
, multiple selections available,
Related content
getListBoxItem
getListBoxItem
More like this
addListBoxItem
addListBoxItem
More like this
getListBoxSelItems
getListBoxSelItems
More like this
findDropListItem
findDropListItem
More like this
setListBoxHandler
setListBoxHandler
More like this
createListBox
createListBox
More like this