Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-11-14
6
Medium Priority
?
167 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

782 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