Solved

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

Posted on 2006-11-14
6
156 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

9 Experts available now in Live!

Get 1:1 Help Now