GetSelIndex Function (ComboBox ListBox ListView PopupList RadioList)

Class

  • ComboBox
  • ListBox
  • ListView
  • PopupList
  • RadioList

Action

Returns the index of the selected item in the combo box, list, single-selection list box, listview, popuplist, or radiolist.

Availability

This functionality is supported only if you are using the Classic Agent.

Syntax

iIndex = list.GetSelIndex()
Variable Description
iIndex The index of the selected item. INTEGER.

Notes

  • GetSelIndex returns the numeric index (1-based) of the selected item in a list. If no item is selected, GetSelIndex returns zero (0). For multi-selection or extend-selection lists, GetSelIndex returns the first selected item.
  • When testing a radiolist for Windows Forms, the index property is unreliable. The visual editor's code generator creates the code that adds the radioitems to the parent. As a result, the index value might be assigned in an unexpected sequence. For example, if you have items A, B, and C, they might be assigned indices 3, 2, and 1. If you select item A, which is the first item, the index value of 3 is returned. You can manually change the application that you are testing to ensure that the items are in the correct order. Or, you can use GetSelItem, which uses the radiolist caption rather than the index.
  • The GetSelIndex function is not available in the ListViewEx class, which is the equivalent of the ListView class on the Open Agent. To achieve the same functionality for a listview on the Open Agent, use the SelectedIndices property of the ListViewEx class.

Example

INTEGER iIndex
iIndex = Find.Open.Files.GetSelIndex()