title: How to save virtual listview immediately after it displays data?
body: <p>I want to save data in virtual listview immediately after it is filled. If I use Savedialog to save data, it works. If I call save procedure in ListviewOnData event, it prompts Error " Can not create file...". I reproduce my observation here. </p>
  
  <pre><code>procedure TForm6.savefileList(AListView: TListView; sFileName: string);
  
  begin
  F:= TFileStream.Create(sFileName, fmCreate or fmOpenRead);
  ...                                                       
  ...
  F.free;
  
  end;
  
  Procedure Tform6.SavevirtualistinSaveDialog;// A buttonClick calls this procedure
  begin
  If SaveDialog1.execute then
  savefilelist(listview1, savedialog1.FileName);; // It works and save data in sfilename.
  ..
  end;
  
  procedure TForm6.ListView1Data(Sender: TObject; Item: TListItem);
  begin
  
  
  with ld do begin     
  ...
  ...
  // filling data in virtual list
  
  end;
               // Right after filling data, I call Dosavelist procedure.
  Dosavelist; //error line " Can not Create file", If I annotate this line
              // and call SavevirtualistinDialog in another buttonClick event, 
              //the data can be saved.
  
  end;
  
  Procedure Tform6.Dosavelist;
  begin
  savefilelist(listview1, extractfilepath(application.exename)+'list.tmp');
  end;
  </code></pre>
  
  <p>I expect save the data in listview (virtual mode) right after it is filled. But it prompts errors.</p>
  
  <p>How to solve it. Thank you in advance. </p>
  
  <p><strong>New Edit:</strong></p>
  
  <p><strong>I delete Dosavelist from listview1data event and put it in another function that tracks listview. It works. So it is solved. 
  Thank you all for help.</strong> </p>
  
  <pre><code>//My complete savefilelist para is:
  
  savefilelist(listview1, extractfilepath(application.exename)+'list.tmp'); 
  
  //In SavevirtualistinSaveDialog procedure, the complete save code line is: 
  
  savefilelist(listview1, savedialog1.FileName);
  </code></pre>
  
  <p>Or Dosavelist procedure may not be called there? Where? How can I capture the moment when the virtual listview has just finished being filled? I do not know what event that is right after ListviewData event?</p>
  
  <p>Thank you again.</p>