Having recently received a 'Tumbleweed' badge for my last question, I am not sure whether I should be asking any more questions, but here goes.
I am populating a TComboBox
with items from a sqlite table and this works fine. In my previous version of Delphi I was able to use ComboBox1.Sorted := True;
to sort the items, but this seems to have disappeared in Delphi 10.2. I can sort the items in the table by applying a query and then populate the TComboBox
from the sorted table. However, for curiosities sake I would like to find out how one now sorts items in a TComboBox
. I have found some references to TComboBox(Sort:Compare)
but have not succeeded in getting this to work to as of yet.
Can somebody please shed some light on this - many thanks
In Firemonkey you can populate a
TComboBox
instance either simply with theItems
property of typeTStrings
or you addTListBoxItem
instances with the form designer. But internally alwaysTListBoxItem
for the elements is used.To use the
TComboBox.Sort
you need to provide an anonymous compare-function.This is a simple example usage of
TComboBox.Sort