TListView Column Sort (Sort by first two columns)

非 Y 不嫁゛ 提交于 2019-12-05 14:50:58

Set SortType to 'stBoth', and implement an OnCompare event handler. Example:

procedure TForm1.ListView1Compare(Sender: TObject; Item1, Item2: TListItem;
  Data: Integer; var Compare: Integer);
var
  S1, S2: string;
begin
  S1 := Item1.Caption;
  if Item1.SubItems.Count > 0 then
    S1 := S1 + Item1.SubItems[0];
  S2 := Item2.Caption;
  if Item2.SubItems.Count > 0 then
    S2 := S2 + Item2.SubItems[0];

  Compare := CompareText(S1, S2);
end;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!