Solved

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

Posted on 2006-11-14
6
160 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
[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
  • 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
Independent Software Vendors: 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!

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

762 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