DesktopListBox.RowSelectedAt

From Xojo Documentation

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

Property (As Boolean )
aDesktopListBox.RowSelectedAt(row as Integer) = newBooleanValue
or
BooleanValue = aDesktopListBox.RowSelectedAt(row as Integer)

New in 2021r3

Supported for all project types and targets.

Gets or sets the selection status of the passed Row.

Notes

Selected is True if the row passed is selected. This property can be used to determine if the row is selected and to select the row. For example,

Listbox1.RowSelectedAt(1) = True //selects the second item in the first column.

Examples

Select Multiple Rows

In order to select multiple row, the RowSelectionType must be set to Multiple. This code selects only the even-numbered rows:

ListBox1.ListIndex = DesktopListBox.NoSelection // Deselect all rows

For i As Integer = 0 To ListBox1.LastRowIndex
If i Mod 2 = 0 Then
ListBox1.RowSelectedAt(i) = True
End If
Next

Getting the list of selected rows

If you allow multiple rows to be selected (see RowSelectionType), you may want to establish a list of all the rows selected. The following example shows how to achieve that:

Var selectedRows() As Integer // Will hold the index of each selected row

For row As Integer = 0 To ListBox1.LastRowIndex
If ListBox1.RowSelectedAt(row) Then
selectedRows.AddRow(row) // This row is selected
End If
Next