急,,数据库问题。(81分)

  • 主题发起人 主题发起人 chatop
  • 开始时间 开始时间
C

chatop

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure addcap;//写入标题过程
var
iCount: Integer;
begin
form1.SeSkinSListView1.Clear;
for icount:=1 to form1.ado1.FieldCount -1 do
begin
form1.seskinslistview1.Columns.Add.Caption :=(form1.ado1.Fields[icount].FieldName);
form1.ado1.Next;
end;
end;
我用以上代码从数据库中读出字段名,写到listview的columns.caption中去,
但我不知道,怎么样才能把数据库中的所有数据写到listview的subitmes.caption中去.
说明白一点!
就是一个mdb数据库有7个字段,比如说
a b c d e f g
然后各各字段下面都有若干记录,,我应该怎么把这些记录读出来,然后放到
相映的字段里面去?
说明一下,一定要用listview!
谢谢了!!

分不够了,不知道专家分能不能用呀?

 
var
i: integer;
lvitem: tlistitem;
begin
for i:=0 to adotable1.FieldCount-1 do
listview1.Columns.Add.Caption:=adotable1.Fields.FieldName;

adotable1.First;
while not adotable1.Eof do
begin
lvitem:=listview1.Items.Add;
lvitem.Caption:=adotable1.Fields[0].Value;
if adotable1.FieldCount>1 then
begin
for i:=1 to adotable1.FieldCount-1 do
lvitem.SubItems.Add(adotable1.Fields.value);
end;
adotable1.Next;
end;
 
接受答案了.
 
后退
顶部