Solved

How to get all data from a TListView into a TMemo?

Posted on 2006-11-14
6
158 Views
Last Modified: 2010-04-05
Hi folks,

I have a Tlistview with three columns. How can I get all this info in my TMemo?

So I can use Memo.lines.add and add the three items into it?

If you need more info please ask.

Kind regards,

Paul

Ps working samples do the trick
0
Comment
Question by:PeterdeB
  • 3
  • 3
6 Comments
 
LVL 19

Expert Comment

by:MerijnB
ID: 17941333
do you need to 'keep' the layout? If so, how, seperated by tabs? Or just the contents, don't care about the layout...?
0
 

Author Comment

by:PeterdeB
ID: 17941519
Hey MerijnB!

This is what I'm trying to accomplish > 
In my listview I have description and then itemtoinstall (both in one row)

for i:= 0 to lv.Items.Count-1 do

  Memo1.Lines.Add('REG ADD %KEY%\00'+IntToStr(i)+' /VE /D '+'"'+lv.Items.Item[i].caption+'"'+ ' /f'+#13+#10+
  'REG ADD %KEY%\00'+IntToStr(i)+' /V 1 /D '+'"%RD%'+ lv.Items.Item[i].caption+'"'+ ' /f'+#13+#10);


This shoudl then result into adding this text into my memo:

REG ADD %KEY%\001 /VE /D "description" /f
REG ADD %KEY%\001 /V 1 /D "itemtoinstall /qb" /f


kind regards,

Paul

The first caption is referred to as 0 and the second as 1, right? So that is a problem when I wnat to loop through all the listview items..
0
 
LVL 19

Accepted Solution

by:
MerijnB earned 500 total points
ID: 17941583
no, the first column is the .Caption property. All other columns are found in the .SubItems property. This is of type TStrings where .SubItems[0] is the contents of the 2nd column (that is to make it easy :))

for i:= 0 to lv.Items.Count-1 do
begin
  Memo1.Lines.Add('REG ADD %KEY%\00'+IntToStr(i)+' /VE /D '+'"'+lv.Items.Item[i].caption+'"'+ ' /f'); // add stuff from 1st column (caption)
  Memo1.Lines.Add('REG ADD %KEY%\00'+IntToStr(i)+' /V 1 /D '+'"%RD%'+ lv.Items.Item[i].SubItems[0]+'"'+ ' /f'); // add stuff from 2nd column (subitems[0]);
end;
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:PeterdeB
ID: 17941720
Yess....muchos gracias! :-)

One thing more > how can I get rid from the 'index is out of bounds error(0)?

Kind regards,

Paul
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 17941799
that means that there is nothing in the second column for one of the lines, is this correct?
anyway, you can do something like:

var
 i: integer;
 j: integer;
for i:= 0 to lv.Items.Count-1 do
begin
  Memo1.Lines.Add('REG ADD %KEY%\00'+IntToStr(i)+' /VE /D '+'"'+lv.Items.Item[i].caption+'"'+ ' /f'); // add stuff from 1st column (caption)
  for j := 0 lv.Items.Item[i].SubItems.Count -1
  Memo1.Lines.Add('REG ADD %KEY%\00'+IntToStr(i)+' /V 1 /D '+'"%RD%'+ lv.Items.Item[i].SubItems[j]+'"'+ ' /f'); // add stuff from the other columns
end;

this way always all columns are copied.
0
 

Author Comment

by:PeterdeB
ID: 17945970
Hi MerijnB,

Actually there was something in the second column. Not sure what caused it since when I gave it another shot I did not get that message anymore. I had implemented a try except and after that I did not get that message anymore. Could be coincedence. Anyway...it works now thanks a lot!

Kind regards,

Paul
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert wav to mp3 in delphi 9 200
Virtuailstring tree add node to another virtuailstring tree list 4 115
Delphi Yen format 3 35
Tvertscrollbox like a whatsapp layout 5 28
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

810 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