Alpha_AI
asked on
How do I do a filter in a ListView
Hello I want the computer to find selected words in a ListView and highlight each of those words then reduce the ListView for display purposes to only contain the filtered results.
Anyone know how or got some code for it.
Ben
Anyone know how or got some code for it.
Ben
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, strutils, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
Edit1: TEdit;
procedure Edit1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
StrList : TStringList;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
Index : Integer;
begin
StrList := TStringList.Create;
for Index := 0 to ListView1.Items.Count -1 do
StrList.Add(ListView1.Item
end;
procedure TForm1.Edit1Change(Sender:
var
Index : Integer;
begin
ListView1.Clear;
for Index := 0 to StrList.Count - 1 do
if Pos(Edit1.Text, StrList.Strings[Index]) > 0 then
ListView1.AddItem(StrList.
if Edit1.Text = '' then
for Index := 0 to StrList.Count - 1 do
ListView1.AddItem(StrList.
end;
end.