Listbox Headers

Have set up listbox with headers to take advantage of sort facility. That’s OK. Now I want to get a column name but the method is not apparent. the help facility does not offer much except heading now deprecated to headerat. Debugger says both are not recognised, so how do you get a column name?

Columns don’t have names.

HeaderAt is probably showing deprecated because they marked Listbox as deprecated. DesktopListbox still uses HeaderAt according to the documentation: DesktopListBox — Xojo documentation

Well text content then. headerat(0)=“zero” works so appears on the Listbox. Repeated for 12 columns with individual names(text, titles, call it what ever). Subsequently need to get the name for column 6 say.

Ah, I understand now, you don’t know the terminology you’re looking for. I was extremely confused at first.

The HeaderAt method is overloaded, as you can tell from the documentation. This means it does multiple things depending on what signature you’re using. I linked directly to the readable method which will give you the Header value for that column.

Thanks Tim, so it can be done. How do I invoke the readable method?

I see now that the documentation is lacking here. Please send a note to Xojo to let them know what pieces of information you need help finding because I am in an awkward position where I haven’t actually myself got stuck. I find that I keep having to explain basics though, so no worries – it’s not you.


The as String part of the method signature lets us know that it returns a String to us. Likewise, the signature below assigns String means it accepts an assignment as a variable would.

So you’ve already used the assigns String method and can see how that’s used. To get a value from an as String method you need ask for the String by putting it into a variable or passing it along to something accepting a String.

// Store it in a variable
var sHeaderAtSix as String = MyDesktopListbox.HeaderAt(6)

// Or pass it along
System.DebugLog(MyDesktopListbox.HeaderAt(6))

Please do send a note to Xojo asking for the improvements to the documentation that you need. They are trying really hard.

2 Likes

There is also the Intro to Xojo Programming textbook which is geared toward learning Xojo:

I think I have already tried that without success but I will have another go. While we have been having this conversation I thought a simpler hammer and bash approach might be better: i.e. place all the titles in an array (possibly global) and handle everything from there.
I will put in a note to Xojo as you suggest. Thanks for your help.

I’d strongly recommend trying what @Tim_Parnell suggested, even if you don’t end up using it. :wink: