先把label,dbedit的tag设置为1开始的连续数
var i,j : integer;
begin
for i := 0 to ComponentCount -1 do
begin
if components is TLabel then
begin
j := TLabel(Components).tag;
if j < table1.RecordCount then
begin
table1.First;
table1.moveby(j-1);
TLabel(Components).Caption := table1.FieldByName('caption').AsString;
end;
if components is TDBEdit then
begin
j := TDBEdit(Components).tag;
if j < table1.RecordCount then
begin
table1.First;
table1.moveby(j-1);
TDBEdit(Components).Caption := table1.FieldByName('caption').AsString;
end;
end;
end;