From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Property (As Integer )
aDesktopListBox.SelectedRowIndex = newIntegerValue
IntegerValue = aDesktopListBox.SelectedRowIndex

New in 2021r3

Supported for all project types and targets.

The number of the selected row.


If no item is selected, SelectedRowIndex returns ListBox.NoSelection. If the DesktopListBox is in multiple-row selection mode, then the number of the lowest selected row is returned. For example, if rows 1, 3, and 4 are selected, SelectedRowIndex returns 1.

You can put the DesktopListBox into multiple-row selection mode by changing the RowSelectionType property.

Sample Code

The following code in the SelectionChanged event handler displays the text in the first column of the selected row:

If Me.SelectedRowIndex >= 0 Then
MessageBox(Me.CellTextAt(Me.SelectedRowIndex, 0))
End If

The following code displays a message if no row is selected:

If ListBox1.SelectedRowIndex = ListBox.NoSelection Then
MessageBox("Please select a row first.")
End If