x:=235; for i:=1 to 8 do begin 1 GetAuditData(AuditData[i]); 2 with TQRLabel(findcomponent('QRLabel'+inttostr(x))) do Caption :=InttoStrmyxdatas.QSendAud.FieldByName'totalnum').AsInteger); 3 inc(x); end;
x:=235; for i:=1 to 8 do begin 1 GetAuditData(AuditData[i]); if findcomponent('QRLabel'+inttostr(x)) then //加上这句判断一下是否找到 2 with TQRLabel(findcomponent('QRLabel'+inttostr(x))) do Caption :=InttoStrmyxdatas.QSendAud.FieldByName'totalnum').AsInteger); 3 inc(x); end;其实出错的原因是你的这个QRLabel的owner的问题,因为findcomponent只是找当前这个control的component,他不会去找子control的所含component.
menliwxj(有缘): 还是不行啊,加上 if findcomponent('QRLabel'+inttostr(x)) then 会提示 'Type of expression must be BOOLEAN',不能编译!!
按你的方法也出错
for i:=1 to 8 do
begin
1 GetAuditData(AuditData[i]);
if findcomponent('QRLabel'+inttostr(x)) then //加上这句判断一下是否找到
2 with TQRLabel(findcomponent('QRLabel'+inttostr(x))) do
Caption :=InttoStrmyxdatas.QSendAud.FieldByName'totalnum').AsInteger);
3 inc(x);
end;其实出错的原因是你的这个QRLabel的owner的问题,因为findcomponent只是找当前这个control的component,他不会去找子control的所含component.
还是不行啊,加上 if findcomponent('QRLabel'+inttostr(x)) then 会提示
'Type of expression must be BOOLEAN',不能编译!!