Disabling Sort in a Hierarchial Listbox

Hello all,

I’m new here :slight_smile: I should mention that this thing I am building is purely for my own interest and education, retrieving Bible data. I’ve owned Xojo for quite a few years but have only recently got started with it though I come from a plethora of other languages.

I’m reading Bible/Book/Chapter information from a REST source. I’m populating a Listbox with folders which represent this hierarchy so it’s quite important that I get the order right. I populate with Bible Versions first then on an ExpandRow event I get the Books (adding Folders) and then the same for the Chapters etc, right down to the Verses

I’ve searched the documentation and forum for a way to disable the sort on a Hierarchical Listbox and perhaps I’m missing something but I cannae find anything obvious. I’ve found all the info for doing it with a “regular” Listbox. If I cannot do this then I suppose my next resort is to a 3rd party TreeView?

Note, I also tried a second column with the number of the Book (and sorting on that column) in it but of course, that’s a string and so the sorting is still wrong :frowning:

So, I guess my question is… Does a Hierarchical Listbox always sort?

Any help appreciated!

Mark

No. It is enough to return True in the HeaderPressed event handler to suppress the automatic sorting in a listbox.

I think I must not have explained well enough…

The ListBox is sorting as I add Folders, I have no headers so no HeaderPressed event :frowning:

Wait, I found the problem, it’s the Dictionary behind the scenes which is doing the dirty work. Belay my question, Doh!

Ah! I was about to ask you to share the code you use to fill the listbox, because it usually does not auto sort. Good to hear you found the bug!