---
title: "getListViewSelItems"
canonical: "https://help.vicon.com/space/Shogun17/13536609/getListViewSelItems"
format: markdown
---
# Description

Gets the selected items in a list view user control

This command returns an array of the indices of the selected items in a list view user control. The indices are zero-based. The indices are returned in the order that the items were selected in, meaning that they may not be in ascending order.

If the list view was created using the `-singleSel` flag, the command will return an array of size 1.

## Functional area

User Window

# Command syntax

## Syntax

|  |
| --- |
| `getListViewSelItems userControlID` |

### Arguments

| **Name** | **Type** | **Required** | **Comments** |
| --- | --- | --- | --- |
| `userControlID` | integer | yes | The ID of the list view to operate on |

### Flags

None

## Return value

integer array

Returns an array of the indices of the selected items in the list view 

> Macro (scroll-pagebreak)

## Examples

```plaintext
// Demonstrate usage of a List View User Control
int $windowID, $listViewID, $formID;
 
// Destroy window if it already exists
if( `windowExists "ListViewTesting"` == true )
    {
      destroyWindow "ListViewTesting";
    } 

  
// Create window and list view and position them
$windowID = `createWindow "ListViewTesting"`;
$formID = `getTopLevelForm $windowID`;
$listViewID = `createListView $windowID -form $formID -checkBoxes`;

  
setControlAnchor $listViewID "left" "left" 3;
setControlAnchor $listViewID "top" "top" 3;
setControlAnchor $listViewID "right" "right" 3;
setControlAnchor $listViewID "bottom" "bottom" 3;
 
// Create the columns
string $columns[3];
int $widths[3];
$columns[0] = "Name";
$columns[1] = "Age";
$columns[2] = "Gender";
$widths[0] = 150;
$widths[1] = 50;
$widths[2] = 100;
setListViewColumns $listViewID $columns $widths;

  
// Add some items to the list view. The text we supply is for the first
// column.
// We supply text for subsequent columns using setListViewItemText
addListViewItem $listViewID "Bob";
addListViewItem $listViewID "Mary";
addListViewItem $listViewID "Jim";
addListViewItem $listViewID "Ann";
 
// Set additional details
setListViewItemText $listViewID 0 1 "50";
setListViewItemText $listViewID 0 2 "Male";
setListViewItemText $listViewID 1 1 "32";
setListViewItemText $listViewID 1 2 "Female";
setListViewItemText $listViewID 2 1 "21";
setListViewItemText $listViewID 2 2 "Male";
setListViewItemText $listViewID 3 1 "44";
setListViewItemText $listViewID 3 2 "Female";
 
// Set the check box to true for the males.
setListViewItemCheck $listViewID 0 true;
setListViewItemCheck $listViewID 2 true;
 
// Change Bob's name
setListViewItemText $listViewID 0 0 "Ken";
 
// Select Mary and Jim 
selectListViewItem $listViewID 2 true;
selectListViewItem $listViewID 1 true;
 
// Print out some of what we just did
print( `getListViewSelItems $listViewID` );
print( `getListViewItemText $listViewID 1 2` );
print( `getListViewItemCheck $listViewID 1` );
print( `getListViewItemCheck $listViewID 0` );
layoutForm $formID;
```

# Additional information

## Related commands

- [addListViewItem](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13537671)
- [createListView](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13537621)
- [deleteAllListViewItems](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13536445)
- [getListViewItemCheck](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13536613)
- [getListViewItemText](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13536611)
- [getNumListViewItems](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13536639)
- [selectListViewItem](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13537214)
- [setListViewColumns](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13537156)
- [setListViewHandler](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13537154)
- [setListViewItemCheck](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13537168)
- [setListViewItemText](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13537166)