delphi - How to save virtual listview immediately after it displays data? -


i want save data in virtual listview after filled. if use savedialog save data, works. if call save procedure in listviewondata event, prompts error " can not create file...". reproduce observation here.

procedure tform6.savefilelist(alistview: tlistview; sfilename: string);  begin f:= tfilestream.create(sfilename, fmcreate or fmopenread); ...                                                        ... f.free;  end;  procedure tform6.savevirtualistinsavedialog;// buttonclick calls procedure begin if savedialog1.execute savefilelist(listview1, savedialog1.filename);; // works , save data in sfilename. .. end;  procedure tform6.listview1data(sender: tobject; item: tlistitem); begin   ld begin      ... ... // filling data in virtual list  end;              // right after filling data, call dosavelist procedure. dosavelist; //error line " can not create file", if annotate line             // , call savevirtualistindialog in buttonclick event,              //the data can saved.  end;  procedure tform6.dosavelist; begin savefilelist(listview1, extractfilepath(application.exename)+'list.tmp'); end; 

i expect save data in listview (virtual mode) right after filled. prompts errors.

how solve it. thank in advance.

new edit:

i delete dosavelist listview1data event , put in function tracks listview. works. solved. thank help.

//my complete savefilelist para is:  savefilelist(listview1, extractfilepath(application.exename)+'list.tmp');   //in savevirtualistinsavedialog procedure, complete save code line is:   savefilelist(listview1, savedialog1.filename); 

or dosavelist procedure may not called there? where? how can capture moment when virtual listview has finished being filled? not know event right after listviewdata event?

thank again.

this sounds if don't specify absolute file path. windows relies on current working directory when saving file. save dialog sets directory, works. in listviewondata event, cwd isn't set correctly.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -