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;
 

――――――――――――――――

原文链接:https://blog.csdn.net/chinazhd/article/details/7311002

相关阅读 >>

Delphi xe10.x 快捷失灵解决办法

Delphi stringtobase64、base64tostring两个函数

Delphi 使用windows api(wincrypt)计算文件md5哈希,支持大文件

Delphi dbgrid中实现copy、paste功能

Delphi append 追加内容到文件中

Delphi7调用Delphi xe2 中间层注意事项

Delphi 通过控件句柄获取控件实例

Delphi idhttp post 普通提交乱码处理

Delphi 给字加边的又一个算法

Delphi 判断进程名是否存在,如果存在则结束进程

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



打赏

取消

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

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

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

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

评论

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