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 tadoquery的用法

Delphi 在目录后面加上一个 "\"

Delphi使用ixmlhttprequest 简单获取网页源代码

Delphi 请求时间,为当前时间,数值为1970-01-01以来的毫秒数

Delphi 屏幕dpi计算

Delphi windows 获取指定进程句柄数

Delphi截取字符串

Delphi 模拟网站验证码

Delphi中使用自定义字体

Delphi 使用shgetfileinfo函数获取任何文件大图标

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



打赏

取消

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

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

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

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

评论

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