Delphi XE5的新功能“ TListView内置搜索过滤”


本文整理自网络,侵删。

 
在窗体的OnCreate事件中初始化TListView项。

procedure TForm1.FormCreate(Sender: TObject);
const
  Books: array [0 .. 4] of string = (
    'Delph abc',
    'Delphi XE2入门',
    ' by DelphiXE',
    'Delphi 2009 handbook');
var
  Book: string;
begin
  for Book in Books do
  begin
    ListView1.Items.Add.Text := Book;
  end;
end;
在Button1的OnClick事件中执行搜索过滤。

procedure TForm1.Button1Click(Sender: TObject);
var
  SearchResponder: ISearchResponder;
begin
  SearchResponder := ListView1 as ISearchResponder;
  SearchResponder.SetFilterPredicate(
    function(Arg: string): Boolean
    begin
      Result := Arg.StartsWith('Delphi');
    end);
end;

相关阅读 >>

Delphi 获取文件的最新修改时间

[Delphi] 计算目录大小的函数,获得目录文件列表,计算文件的大小

Delphi 用文字作为窗体的形状

Delphi调试服务程序的两种方法

Delphi 删除任意文件的任意位置的任意数量的字符

Delphi程序升级到64位

Delphi kbmmw安装

Delphi 如何快速读写文件中的字符串

Delphi windows 底下根据一个进程的名字杀死一个进程的代码

Delphi 比较图片是否相同

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



打赏

取消

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

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

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

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

评论

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