ListBox.Sort

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

ListBox.Sort()

Supported for all project types and targets.

Sorts the rows based on the current values of the SortingColumn and ColumnSortDirectionAt properties.

Notes

When AllowExpandableRows is True and a ListBox is sorted, the rows are sorted at all levels of the hierarchy, not just the base level.

To ensure the sort indicator displays after sorting you can force the header to refresh like this:

Listbox1.HasHeader = True

Example

The following code sorts a Listbox in descending order on the first column.

// first column, descending order
ListBox1.ColumnSortDirectionAt(0) = ListBox.SortDirections.Descending
ListBox1.SortingColumn = 0 // first column is the sort column
ListBox1.Sort