delphi ListView 排序功能


本文整理自网络,侵删。

 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 xp 之后, Delphi 动注册表不方便了...逼出来一个办法:

Delphi extractfileext() 获取文件后缀的函数

Delphi中dataset和json的互转

干掉360保险箱vb/vc/Delphi 源码

Delphi-idhttp-json用法

Delphi 大小写字符串转换

Delphi xe 跨平台(windows、android安卓、苹果macos、苹果ios)写法

Delphi memo 文本列合并

Delphi xe安装2010版控件

Delphi 延时程序

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...