SelectedIndex PowerScript function
Description
Obtains the number of the selected item in a ListBox or ListView
control.
Controls
ListBox and ListView controls
Syntax
1 |
<span>listcontrolname</span>.<span>SelectedIndex</span> ( ) |
Argument |
Description |
---|---|
listcontrolname |
The name of the ListBox or ListView control |
Return Values
Integer. Returns the index of the selected
item in listcontrolname. If more than one item
is selected, SelectedIndex returns the index
of the first selected item. If there are no selected items or an
error occurs, SelectedIndex returns -1. If listcontrolname is null,
SelectedIndex returns null.
Usage
SelectedIndex and SelectedItem are
meant for lists that allow a single selection only (when the MultiSelect
property for the control is false).
When the MultiSelect property is true, SelectedIndex gets
the index of the first selected item only. Use the State function,
instead of SelectedIndex, to check each item
in the list and find out if it is selected. Use the Text function
to get the text of any item in the list.
Examples
If item 5 in lb_actions is
selected, then this example sets li_Index to
5:
1 |
integer li_Index |
1 |
li_Index = lb_actions.<span>SelectedIndex</span>() |
These statements open the window w_emp if
item 5 in lb_actions is selected:
1 |
integer li_X |
1 |
li_X = lb_actions.<span>SelectedIndex</span>() |
1 |
If li_X = 5 then Open(w_emp) |