2017年9月7日 星期四

ListView排序

procedure TForm1.ListView1Compare(Sender: TObject; Item1,
  Item2: TListItem; Data: Integer; var Compare: Integer);
begin
  Compare := CompareText(Item1.caption, Item2.caption);
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
 listview1.AlphaSort;
end;


將subitems納入排序 (Listview Column2)

procedure TForm1.ListView1Compare(Sender: TObject; Item1,
  Item2: TListItem; Data: Integer; var Compare: Integer);
begin
  Compare := CompareText(Item1.subitems[0], Item2.subitems[0]);
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
 listview1.AlphaSort;
end;

沒有留言:

張貼留言