What has happened to ComboBox.Sorted := True; in Delphi 10.2?

丶灬走出姿态 提交于 2019-12-02 10:14:30

In Firemonkey you can populate a TComboBox instance either simply with the Items property of type TStrings or you add TListBoxItem instances with the form designer. But internally always TListBoxItem 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

cbxItems.Sort(
  function (pLeft, pRight: TFMXObject): Integer
  var
    lLeft, lRight: TListBoxItem;
  begin
    lLeft := TListBoxItem(pLeft);
    lRight := TListBoxItem(pRight);
    Result := String.Compare(lLeft.Text, lRight.Text);
  end
);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!