[CLOSED] ListView vsReport Search lazarus / 31-LCL ---------------------------------------------------------------------- Pe3s · 2021-12-03 18:23 I wrote the code for the ListView search engine, but it does not mark the items, what do I need to correct? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.BitBtn4Click(Sender: TObject);var  i, licznik: integer;begin  licznik := 0;  for i:=0 to ListView1.Items.Count -1 do  begin       ListView1.Items[i].Selected := false;        if pos(Edit5.Text, ListView1.Items[i].Caption)<>0 then        begin          ListView1.Items[i].Selected := true;          licznik := licznik+1;      end;  end;  if licznik=0 then showmessage('Not Found'); end; ---------------------------------------------------------------------- Pe3s · 2021-12-04 06:28 Yes, Multiselect: = True; ---------------------------------------------------------------------- paweld · 2021-12-04 07:03 listview by default does not show a selection unless focus is set on it. You can either enable showing the selection: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ListView1.HideSelection := False;or set focus on the listview after the search is complete Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if licznik = 0 then    ShowMessage('Not Found')  else    ListView1.SetFocus; ---------------------------------------------------------------------- Pe3s · 2021-12-04 09:13 Thank you, I have one more question, what do I have to change in the code to find each matching element in turn? ---------------------------------------------------------------------- paweld · 2021-12-04 11:11 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.BitBtn4Click(Sender: TObject);var  i, s: Integer;  found: Boolean;begin  if ListView1.Items.Count = 0 then    exit;  found := False;  ListView1.MultiSelect := False;  ListView1.HideSelection := False;  s := 0;  if Assigned(ListView1.Selected) then    s := ListView1.Selected.Index;  if s < ListView1.Items.Count - 1 then    i := s + 1  else    i := 0;  while not found do  begin    if pos(Edit5.Text, ListView1.Items[i].Caption) > 0 then    begin      ListView1.Items[i].Selected := True;      found := True;      break;  end    else    begin      if i = s then        break      else if i < ListView1.Items.Count - 1 then        Inc(i)      else        i := 0;    end;  end;  if not found then    ShowMessage('Not found'); ---------------------------------------------------------------------- Pe3s · 2021-12-04 16:19 @paweld Thank you