Forum > LCL

[CLOSED] ListView vsReport Search

(1/2) > >>

Pe3s:
I wrote the code for the ListView search engine, but it does not mark the items, what do I need to correct?

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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;

jamie:
Did you set the "MultiSelect" property := true ?

Otherwise I think only one will be selected, most likely the last one.

Pe3s:
Yes, Multiselect: = True;

paweld:
listview by default does not show a selection unless focus is set on it.
You can either enable showing the selection:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ListView1.HideSelection := False;or set focus on the listview after the search is complete

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  if licznik = 0 then    ShowMessage('Not Found')  else    ListView1.SetFocus;

Pe3s:
Thank you, I have one more question, what do I have to change in the code to find each matching element in turn?

Navigation

[0] Message Index

[#] Next page

Go to full version