Solved

Saving listview to text file.

Posted on 1998-08-28
2
1,743 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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now