Listbox: avoid the Sort feature

I was using a Listbox and needed a Header but do not wanted the Sort feature. *

So, in the docuentation, I found the use of Return True to do that, but I totally forgot how to avoid the sort indicator icon in the clicked column.

I searched in the local documentation, in the docs online, then start to think “I know I used code to do that, but what was the name of the project ?”.

I was lucky, I recalled the name of the project and found it immediately. Before sharing the code here, I checked in the brand new project. Here is the code (in the SortColumn Event):

[code]Function SortColumn(column As Integer) As Boolean
//
// Disable the Sort feature
//

// To avoid the sort indicator icon
Me.SortedColumn = -1
Me.HasHeading = False
Me.HasHeading = True

// To not make any sort
Return True
End Function[/code]

To Paul: it may be a good idea to add the code in the documentation (easier to find in the docs vs the forum).

  • I just realized (too late) that I could used a second Listbox (without header, 1 Row only) on top of the other (the displayer) to display my header: disallowing the Sort feature was not needed, but… maybe the next time will I remember to do that ?

I use https://documentation.xojo.com/index.php/ListBox.HeaderType
Open event:

Me.HeaderType(-1) = Listbox.HeaderTypes.NotSortable

:wink:

One more for the docs… *

Thanks Alberto

BTW: the good old -1 trick !

  • Edit: and no icon sort direction displayed !