ListBox.HeadingIndex

From Xojo Documentation

Property (As Integer )
aListBox.HeadingIndex = newIntegerValue
or
IntegerValue = aListBox.HeadingIndex

Supported for all project types and targets.

Allows you to get and set the sort column in a ListBox. The first column is numbered zero.

Notes

Using this property sets the sort direction indicator in the header.

You can also sort a ListBox by using the SortedColumn property to set the sort column and the ColumnSortDirection property to set the direction of the sort. Then call the Sort method to do the sort.

Example

This code in the Open event of a ListBox sorts on the first column:

Me.SortedColumn = 0
Me.ColumnSortDirectionAt(0) = ListBox.SortDirections.Ascending
Me.HeadingIndex = 0
Me.Sort