Sorted

This property determines whether the items in a combo or list box are sorted alphabetically.

Usage

oObject.Sorted = lSortThem
lSortThem = oObject.Sorted
Help says that Sorted applies only if RowSourceType is 0 or 1, meaning you're either adding the items with AddItems or providing them explicitly. What it doesn't say is that you can't even set Sorted to .T. for any other RowSourceType—you can't.Changing Sorted changes the ListIndexes (but not the ListItemIds) of the items in the list or combo. Also, when Sorted is .T., new items are added at the correct index in the list, which means the index of other items can change.Beware—the sort is case-sensitive (unless you SET COLLATE TO "GENERAL", which is not generally a good idea).One interesting point here. If you set Sorted to .T., then later change it to .F., the items stay in sorted order until you do something that changes their order. This does offer the possibility of a neat trick for getting a case-insensitive sort. SET COLLATE TO "GENERAL", turn Sorted on, then SET COLLATE back to "MACHINE" where you usually want to keep it. (Just be careful not to do anything you don't mean while COLLATE is at "GENERAL".) Of course, this only works if you have a fixed list.

Example

lstFlavors.RowSourceType = 1  && explicit list
lstFlavors.RowSource = "Chocolate,Vanilla,Strawberry," + ;
                       "Butter Pecan,Cherry Vanilla,Coffee"
lstFlavors.Sorted = .T.

See Also

AddItem, AddListItem, ComboBox, ListBox, ListIndex, ListItemId, RemoveItem, RemoveListItem, RowSource, RowSourceType


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .