Highlight multiple rows in a listbox programmatically?

According to the documentation, you can use the listbox.rowselectedat(row_index) to highlight a row in a listbox programmatically; however, that does not appear to work because it doesn’t like that syntax in xojo 2025r2.

Any ideas on how to accomplish this?

It compiles and works for me:

MyListbox.RowSelectedAt(row_index) = True

If the multiple selection isn’t working, check to see if the RowSelectionType is set to Multiple.

Check the documentation to see if the specific version of Listbox you are using really has that function. Desktop, API 1.0, and Web all do selecting the row differently.

Found the issue. We subclassed the LISTBOX a number of years ago before API 2.0. Consequently, I had to change the listbox I was using from our subclass to DesktopListbox and then xojo would recognize the command. Something to keep in mind for anyone that has subclassed the basic classes before API 2.0 which we did.

You only needed to use the API 1.0 version of the function which is Listbox.Selected(index)

1 Like