Get a listbox's item's name

I am trying to get the name of an item in a listbox using code, sort of like this…

for x = 0 To mylistbox(1).RowCount - 1
msgbox mylistbox(1).item.text(x)
next x

How do I do this in Xojo? Thanks.

You’re looking for the CellTextAt(row as Integer, column as Integer) as String method.

for index as Integer = 0 to mylistbox.LastRowIndex
  var cellText as String = mylistbox.CellTextAt(index, 0)
1 Like

Using msgBox is not a good idea at all…

Prepare yourself with troubles (one click for each displayed Row); I hope you have less than 3 Rows… to display !

Ah, CellTextAt. I won’t forget that one anytime soon.
Nice work and, now that my problem is solved, I thank you.

I promise not to use msgboxes willy-nilly in the future :slight_smile:

If you’re testing, then system.debuglog is better.

1 Like

If UserCancelled Then Exit

inside the loop is good too :wink: !!!