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 var5 Ix, Sx: Integer;
6 S: string;
7 begin8 AStrings.BeginUpdate;
9 Ix := 0;
10 while Ix < AListView.Items.Count do11 begin12 with AListView.Items[Ix] do13 begin14 S := Caption + Delim;
15 if Assigned(SubItems) then16 begin17 Sx := 0;
18 while Sx < SubItems.Count do19 begin20 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;