function TForm1.getlistviewtext(lv: TListView;flag:Integer): string;
var
i,j,m,n:Integer;
s,s1,s2:string;
begin
result:='';
s:='';
i:=lv.Columns.Count;
m:=lv.Items.Count;
//得出列标题
for j:=0 to i-1 do
begin
s:=lv.Columns[j].Caption;
if flag=1 then//需要将标题内容一起取出
result:=result+s;
end;
//得出单元格所有内容
for n:=0 to m-1 do
begin
s1:=self.ListView1.Items[n].Caption;
result:=result+s1;
for j:=0 to i-2 do
begin
s2:=self.ListView1.Items[n].SubItems[j];
result:=result+s2;
end;
end;
end;如果我要将ListView1中的内容中每行的X,Y列逐条取出,要怎么写呢?
var
i,j,m,n:Integer;
s,s1,s2:string;
begin
result:='';
s:='';
i:=lv.Columns.Count;
m:=lv.Items.Count;
//得出列标题
for j:=0 to i-1 do
begin
s:=lv.Columns[j].Caption;
if flag=1 then//需要将标题内容一起取出
result:=result+s;
end;
//得出单元格所有内容
for n:=0 to m-1 do
begin
s1:=self.ListView1.Items[n].Caption;
result:=result+s1;
for j:=0 to i-2 do
begin
s2:=self.ListView1.Items[n].SubItems[j];
result:=result+s2;
end;
end;
end;如果我要将ListView1中的内容中每行的X,Y列逐条取出,要怎么写呢?
var
i,j,m,n:Integer;
s,s1,s2:string;
begin
result:='';
s:='';
i:=lv.Columns.Count;
m:=lv.Items.Count;
//得出列标题
for j:=0 to i-1 do
begin
s:=lv.Columns[j].Caption;
if flag=1 then//需要将标题内容一起取出
result:=result+s;
end;
//得出单元格所有内容
for n:=0 to m-1 do
begin
if lv.Items[n].Selected then
begin
s1:=lv.Items[n].Caption;
result:=result+s1;
for j:=0 to i-2 do
begin
s2:=lv.Items[n].SubItems[j];
result:=result+s2;
end;
end;
end;
end;
还是不怎么明白,我这个是个歌曲下载软件,我要把ListView2中的歌曲下载到U盘,当点“下载”按钮的时候,它就把ListView2中全部的 歌曲路径+歌曲名字得到文件路径,下载到U盘
listview2的rowselect设置成true老大在帮忙看下,万分感谢,不知道你是哪里的,不然请你吃饭,呵呵!
var
i,j,m,n:Integer;
s,s1,s2:string;
begin
s:='';
i:=self.ListView1.Columns.Count;
m:=self.ListView1.Items.Count;
//得出单元格所有内容
for n:=0 to m-1 do
begin
if self.ListView1.Items[n].Selected then
begin
s1:=self.ListView1.Items[n].Caption;//歌曲路径
s2:=self.ListView1.Items[n].SubItems[0];//歌曲名称
self.Memo1.Lines.Add(s1+s2);
//拷贝该歌曲
end;
end;
end;