T:=0; with listview1 do begin for i:= 0 to Items.count-1 do begin T:=T+StrtoFloat(Items[i].SubItems.Strings[3]); end; end;
procedure TForm1.Button1Click(Sender: TObject); var i:integer; ts:TListItem; total:integer; begin total:=0; for i:=0 to mylv1.Items.Count-1 do begin ts:=mylv1.Items[i]; total:=total+strtoint(ts.SubItems[num]); //num为需统计的列 end; showmessage(inttostr(total)); end;
with listview1 do
begin
for i:= 0 to Items.count-1 do
begin
T:=T+StrtoFloat(Items[i].SubItems.Strings[3]);
end;
end;
var i:integer;
ts:TListItem;
total:integer;
begin
total:=0;
for i:=0 to mylv1.Items.Count-1 do
begin
ts:=mylv1.Items[i];
total:=total+strtoint(ts.SubItems[num]);
//num为需统计的列
end;
showmessage(inttostr(total));
end;