本文整理自网络,侵删。
private
{ Private declarations }
SortCol: Integer;
SortWay: Integer;
procedure TMainFrm.ListView1ColumnClick(Sender: TObject; Column: TListColumn);
begin
SortCol:=Column.Index;
if (SortWay=1) then SortWay:=-1 else SortWay:=1;
(Sender as TCustomListView).AlphaSort;
end;
procedure TMainFrm.ListView1Compare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
var
t: Integer;
begin
if (SortCol=0) then
begin
Compare:=SortWay * CompareText(Item1.Caption,Item2.Caption);
end else
begin
t:=SortCol-1;
Compare:=SortWay * CompareText(Item1.SubItems[t],Item2.SubItems[t]);
end;
end;
相关阅读 >>
Delphi winapi: isiconic、iszoomed - 分别判断窗口是否已最小化、最大化
Delphi idhttp最简洁的修改和取得cookie例子
更多相关阅读请进入《Delphi》频道 >>