procedure TForm1.txtFilterChange(Sender: TObject);
var
i1, i2: integer;
s1: string;
b1: boolean;
begin
if txtFilter.Text = '' then Exit;
s1:= LowerCase(txtFilter.text);
LVU.items.beginupdate;
for i1:= LVU.items.count- 1 downto 0 do begin
b1:= pos(s1, LowerCase(LVU.items[i1].caption)) > 0;
if not b1 then for i2:= 0 to LVU.items[i1].subitems.count- 1 do begin
if pos(s1, LVU.items[i1].subitems[i2])> 0 then begin
b1:= true;
break;
end;
end;
if not b1 then LVU.items.delete(i1);
end;
LVU.items.endupdate;
end;
Code is working perfect but there is problem when i use back space or even delete the searched word , listview become blank and don't show the original results here is my project attached any solve to this problem ?
yes this is the hard part for me i tried to back up the list and combine them with the code sadly i fail , can you help me with that please , what iam trying to achieve is kinda like real time search when i type a word results show up wen back space with one litter result show up when i delete the word actual results shows up
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ in god i trust with every movement i do graduated student and looking for knowledge
you may put your form another listview but invisible state. (visible := false)
Do the same add, delete ext. this shadow listview like LUV listview.
Shadow Listview will be your master list. LUV listview will be for vision.
I'm on the way back to the city I live in and writing from my smartphone.
so keyboard filling a lot of words. when I arrive, i will write an example if you need allready.
i have to get ride of my current code ? and start from scratch , to think about this logic and coding , will be more helpful if i see example " Coding " to get ride of brain wash .
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ in god i trust with every movement i do graduated student and looking for knowledge
procedure TForm1.txtFilterChange(Sender: TObject);
var
i1, i2: integer;
s1: string;
b1: boolean;
begin
if txtFilter.Text = '' then
begin
lvs.Visible:= true;
LVU.Visible := False;
lvs.SelectAll;
lvs.CopySelection(LVU);
end else
begin
LVU.Visible := True;
lvs.Visible:= False;
s1:= LowerCase(txtFilter.text);
LVU.items.beginupdate;
for i1:= LVU.items.count- 1 downto 0 do begin
b1:= pos(s1, LowerCase(LVU.items[i1].caption)) > 0;
if not b1 then for i2:= 0 to LVU.items[i1].subitems.count- 1 do begin
if pos(s1, LVU.items[i1].subitems[i2])> 0 then begin
b1:= true;
break;
end;
end;
if not b1 then
LVU.items.delete(i1);
end;
LVU.items.endupdate;
end;
end;
its kinda work but i cannot show each record after first search when i type mia its shows all results with -M- i need when i do back space with one litter grab resultes of same litters
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ in god i trust with every movement i do graduated student and looking for knowledge
if txtFilter.Text = '' then
begin
lvs.Visible:= true;
LVU.Visible := False;
end else
begin
// always refresh before filter
lvs.SelectAll;
lvs.CopySelection(LVU);
LVU.Visible := True;
lvs.Visible:= False;
s1:= LowerCase(txtFilter.text);
LVU.items.beginupdate;
for i1:= LVU.items.count- 1 downto 0 do begin
b1:= pos(s1, LowerCase(LVU.items[i1].caption)) > 0;
if not b1 then for i2:= 0 to LVU.items[i1].subitems.count- 1 do begin
if pos(s1, LVU.items[i1].subitems[i2])> 0 then begin
b1:= true;
break;
end;
end;
if not b1 then
LVU.items.delete(i1);
end;
LVU.items.endupdate;
end;