Solved

Saving listview to text file.

Posted on 1998-08-28
2
1,771 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

735 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