[SOLVED] Typed files Save and Read ListView lazarus / 31-LCL ---------------------------------------------------------------------- Pe3s · 2021-11-17 19:16 Hello, How to complete the procedures to write and read data from a ListView? 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 type  TMyRecord = record    FirstName: string[100];    LastName: string[100];  end; procedure TForm1.LoadData;begin if not FileExists('D:\Data.dat') then Exit; data := TFileStream.Create('D:\Data.dat', fmOpenRead);  data.Free;end; procedure TForm1.SaveData;begin data := TFileStream.Create('D:\Data.dat', fmCreate);    data.Free;end; ---------------------------------------------------------------------- wp · 2021-11-17 21:31 Look at the attached project and try to understand it. I used a plain old text file for file access because it is easier to handle strings than with streams. ---------------------------------------------------------------------- Pe3s · 2021-11-18 13:05 Thank you, but I wanted to learn TFileStream and typed files.  I will continue to look for a solution. And whether the use of XMLConig will be a good choice? ---------------------------------------------------------------------- wp · 2021-11-18 16:09 Did you edit the first post? IIRC there was no record definition yesterday... I wonder now what this type has to do with the TListView mentioned in the title? Do you mean the the Listview shows two columns, one with the FirstName, the other one with the LastName? ---------------------------------------------------------------------- Pe3s · 2021-11-18 16:17 @wp This is how I edited the post. I am trying to write and read data displayed in two columns, hence the definition of the record. ---------------------------------------------------------------------- wp · 2021-11-18 17:11 Here is another version of the demo project, now with filestream and the record type that you proposed. ---------------------------------------------------------------------- Pe3s · 2021-11-18 18:03 Thank you, I have one more question, I wrote a search engine, but I noticed that if there are several items with the same name, it marks the last thing I need to correct to search in turn 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 var i: Integer;beginfor i := 0 to ListView1.Items.Count -1 dobegin  if Pos(Edit5.Text, ListView1.Items[i].Caption) > 0 then  begin    ListView1.ItemIndex := i;    ListView1.Items[i].MakeVisible(false);  ListView1.SetFocus;    end;  end; ---------------------------------------------------------------------- wp · 2021-11-18 18:58 I'm not sure what you mean. Do you want to replace the duplicate strings? ListView.Items[i ].Caption is the text in the first column, ListView.Items[ i].SubItems[0] the text in the second column, etc. 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.Items[i].Caption := 'new text for 1st column'; ListView1.Items[i].SubItems[0] := 'new text for 2nd column'; ---------------------------------------------------------------------- Pe3s · 2021-11-19 12:56 I meant the ability to search for a record.  my code searches but kezeli there are several records with the same name, it selects the last one and not each one after pressing the button