Solved

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

Posted on 2006-11-14
6
157 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

947 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now