with adoquery1 do begin for i=0 to dbgrid.recordcount-1 do begin listview.items.add(fieldbyname('name').asstring+fieldbyname('age').asinteger); next; end; end; 不知道行不行 姑且一看
如果dbgrid的dataset是adoquery 可以用以下代码实现 var item:TlistItem;with adoquery do begin first; while not Eof do begin Item:=ListView.add; item.caption:=IntToStr(listView.items.count); //添加序号,不是你要求的,但可以考虑添加,呵呵… item.subitems.add(FieldByName('name').asstring); item.subitems.add(FieldByName('age').asstring); next; end end
with adoquery.datasource.dataset do begin first; while not Eof do begin Item:=ListView.add; item.caption:=IntToStr(listView.items.count); //添加序号,不是你要求的,但可以考虑添加,呵呵… item.subitems.add(FieldByName('name').asstring); item.subitems.add(FieldByName('age').asstring); next; end end
begin
for i=0 to dbgrid.recordcount-1 do
begin
listview.items.add(fieldbyname('name').asstring+fieldbyname('age').asinteger);
next;
end;
end;
不知道行不行 姑且一看
可以用以下代码实现
var
item:TlistItem;with adoquery do
begin
first;
while not Eof do
begin
Item:=ListView.add;
item.caption:=IntToStr(listView.items.count); //添加序号,不是你要求的,但可以考虑添加,呵呵…
item.subitems.add(FieldByName('name').asstring);
item.subitems.add(FieldByName('age').asstring);
next;
end
end
begin
first;
while not Eof do
begin
Item:=ListView.add;
item.caption:=IntToStr(listView.items.count); //添加序号,不是你要求的,但可以考虑添加,呵呵…
item.subitems.add(FieldByName('name').asstring);
item.subitems.add(FieldByName('age').asstring);
next;
end
end