Search FireMonkey

TListview does not restart properly when you search, clear the search, and then reload listview. Using XE5.

Steps:

  • After starting the project, enter the text into the search.
  • Clear the search by clicking the "Clear" button or by deleting the search text or by pressing the search button "X".
  • Click the Refresh button. Nothing appears. You can follow the reload procedure and see that each item has been added. However, the total number of lists will be "0" !!!
  • However, if you add the search text back, the elements will reappear. This is madness. And you clear the search again and all the elements will appear. Press the reset button and they will disappear.
  • I tried every trick I can solve and didn't come up with anything. Even when you clear the search, the list is scanned in the search contents.
  • So now listview is a faulty control. If you perform a search, you cannot clear the search and reload the list.
  • I even tried TSearchBox and set "DeleteSelection", "ResetSelection" and "ClearSelection" <> None of these actions work.

Any help with this fancy thing ???

The 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; 
+5
source share

Source: https://habr.com/ru/post/974386/


All Articles