Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Save and load TListView items to / from a file (2) Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
31-Oct-02
Category
Files Operation
Language
Delphi 2.x
Views
96
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

Does anyone one have any idea how to save the content of a TListView to a text file

Answer:

You could save the contents to a TStrings object, and then save the TStrings using 
.SaveToFile.
1   
2   procedure ListViewToStrings(AListView: TListView; AStrings: TStrings; const Delim:
3     string = ';');
4   var
5     Ix, Sx: Integer;
6     S: string;
7   begin
8     AStrings.BeginUpdate;
9     Ix := 0;
10    while Ix < AListView.Items.Count do
11    begin
12      with AListView.Items[Ix] do
13      begin
14        S := Caption + Delim;
15        if Assigned(SubItems) then
16        begin
17          Sx := 0;
18          while Sx < SubItems.Count do
19          begin
20            S := S + SubItems[Sx] + Delim;
21            Inc(Sx);
22          end;
23        end;
24      end;
25      AStrings.Append(S);
26      Inc(Ix);
27    end;
28    AStrings.EndUpdate;
29  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC