FireMonkey TListview Search Reload Issue

  

TListview is not reloading properly when you do a search, clear the search and then reload the listview. Using XE5.

Steps are:

After project is running enter text into search.
Clear search either clicking on “Clear” button or deleting the search text or clicking on the search “X” button.
Press the “Reload” button. Nothing appears. You can step through the reload procedure and see that each item is added. However, the resulting list count is “0”!!!
However, if you add the search text back the items reappear. This is crazy. And you clear the search again and all items appear. Hit the reload button and they disappear.
I have tried every trick I can to solve this and come up with nothing. Even when you clear the search, the listview is holding on to the search contents.
So for now listview is a malfunctioning control. If you do a search you cannot clear the search and reload the listview.
I have even tried TSearchBox and set “DeleteSelection”, “ResetSelection” and “ClearSelection” <> None of these works.

Any help with this quirky thing???

Code is as follows:

procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
LItem: TListviewItem;
begin
if Assigned(Listview1) then
Listview1.Items.Clear;
for i := 1 to 20 do
begin
LItem := Listview1.Items.Add;
LItem.Text := IntToStr(i);
end;
end;

procedure TForm1.btnButton1Click(Sender: TObject); { reload button }
var
i: integer;
LItem: TListviewItem;
begin
btnButton2Click(btnButton2); <<<<edit add
if Assigned(Listview1.Items.Filter) then <<<<edit add
Listview1.Items.Filter := nil; <<<<edit add
if Assigned(Listview1) then
Listview1.Items.Clear;
for i := 1 to 20 do
begin
LItem := Listview1.Items.Add;
LItem.Text := IntToStr(i);
end;
end;

procedure TForm1.btnButton2Click(Sender: TObject); { clear button }
var
i: integer;
SearchBox: TSearchBox;
begin
for i := 0 to Listview1.Controls.Count – 1 do
if Listview1.Controls[i].ClassType = TSearchBox then
begin
SearchBox := TSearchBox(Listview1.Controls[i]);
Break;
end;
if Assigned(SearchBox) then
SearchBox.Text := ”;
end;

Comments are closed.