Delphi的ListView自动排序

private
SortCol: Integer;
SortWay: Integer; procedure TForm1.LVweColumnClick(Sender: TObject; Column: TListColumn);
begin
SortCol:=Column.Index;
if (SortWay=1) then SortWay:=-1 else SortWay:=1;
(Sender as TCustomListView).AlphaSort;
end;
procedure TForm1.LVweCompare(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;

  

上一篇:IE 将“通过域访问数据源”设置为启用(注册表)


下一篇:水果项目第3集-asp.net web api开发入门