Solved

Saving listview to text file.

Posted on 1998-08-28
2
1,769 Views
Last Modified: 2008-03-04
What is the best way to save the contents of a listview to a text file? Any examples would help a lot.

Thanks.
0
Comment
Question by:Kmiller
2 Comments
 
LVL 4

Expert Comment

by:itamar
ID: 1338058
Hi Kmiller,

In fact I made a component, descendant from TListView that has a SaveToFile method.

If you can wait till Monday I can send you the source code (It's in my office...)

Bye,
Itamar
0
 
LVL 3

Accepted Solution

by:
mirek071497 earned 100 total points
ID: 1338059
The easiest way is to use something like this:

procedure TForm1.SaveBtnClick(Sender: TObject);
var st : TFileStream;
begin
  st := TFileStream.Create( 'c:\test.res', fmCreate );
  st.WriteComponent( ListView1 );
  st.free;
end;

procedure TForm1.LoadBtnClick(Sender: TObject);
var st : TFileStream;
begin
  st := TFileStream.Create( 'c:\test.res', fmOpenRead );
  st.ReadComponent( ListView1 );
  st.free;
end;

however this proc reads the settings for the ListView1.too. If you don't like this you can create invisible mListView and assign items from visible to invisible.

You can of course travell over the items with for i:=0 to ListView1.Items.Count and save nodes and subnodes.

Mirek.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question