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

相关阅读 >>

idftp无法设置transfertype属性

Delphi 检测是否包含字符

Delphi 制作一个内网传播的程序

Delphi hex 相关单元

Delphi mailurlmaybeinvalid 检测邮箱地址有效性

windows api 的数据类型与 Delphi 数据类型对照表

Delphi iddecodermime 对图像编码base64解码成图像文件

Delphi 把exe嵌入到自己的exe中。Delphi xe3

Delphi ini文件操作用法

Delphi 10.2 ide界面

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



打赏

取消

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

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

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

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

评论

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