for i:=1 to form3.adotable1.RecordCount do
begin
 with tcheckbox.Create(self) do
 begin
 parent:=self;
   d:=d+1;
   name:='checkbox'+inttostr(i);
   caption:=form3.ADOTable1.Fields[1].asstring;
   left:=30;
   top:=d*20+10;
  end;
我用以上一段程序自动生成了数据表中相应数量的checkbox控件,但我想用caption:=form3.ADOTable1.Fields[1].asstring;取数据表中相应安段的相应行的数据,可是他显示的全是第一条记录的内容。请问哪位知道什么原因呀?

解决方案 »

  1.   

    Form3.ADOTabel1.First;
    for i:=1 to form3.adotable1.RecordCount do
    begin
     with tcheckbox.Create(self) do
     begin
     parent:=self;
       d:=d+1;
       name:='checkbox'+inttostr(i);
       caption:=form3.ADOTable1.Fields[1].asstring;
       Form3.ADOTabel1.Next;
       left:=30;
       top:=d*20+10;
      end;
      

  2.   

    Form3.ADOTabel1.First;
    while not Form3.ADOTabel1.eof do
    begin
     with tcheckbox.Create(self) do
     begin
       parent:=self;
       d:=d+1;
       name:='checkbox'+inttostr(Form3.ADOTabel1.RecNo);
       caption:=form3.ADOTable1.Fields[1].asstring;
       left:=30;
       top:=d*20+10;
       Form3.ADOTabel1.Next;
      end;
      

  3.   

    楼上的说得对,可能你少了个
    ADOTabel1.Next;
      

  4.   

    for i:=1 to form3.adotable1.RecordCount do
     begin
     with tbutton.Create(self) do
     begin
        parent:=self;
        d1:=d1+1;
        name:='button'+inttostr(i);
        caption:='可修改';
        left:=100+k1*250;
        top:=8+d1*44;
        if i=10 then
        begin
        k1:=k1+1;
        d1:=0
        end;
        //if(tbutton) then
        button.OnClick:=btnonclick;
     end;
    我在后面加上了一个button.OnClick:=btnonclick;可为什么老是提示错误说没有定义button!想在里面加上事件,怎么加呀?