PeterdeB
asked on
How to get all data from a TListView into a TMemo?
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
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
do you need to 'keep' the layout? If so, how, seperated by tabs? Or just the contents, don't care about the layout...?
ASKER
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].cap tion+'"'+ ' /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..
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].cap
'REG ADD %KEY%\00'+IntToStr(i)+' /V 1 /D '+'"%RD%'+ lv.Items.Item[i].caption+'
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..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yess....muchos gracias! :-)
One thing more > how can I get rid from the 'index is out of bounds error(0)?
Kind regards,
Paul
One thing more > how can I get rid from the 'index is out of bounds error(0)?
Kind regards,
Paul
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].cap tion+'"'+ ' /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.
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].cap
for j := 0 lv.Items.Item[i].SubItems.
Memo1.Lines.Add('REG ADD %KEY%\00'+IntToStr(i)+' /V 1 /D '+'"%RD%'+ lv.Items.Item[i].SubItems[
end;
this way always all columns are copied.
ASKER
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
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