> > function GetMyLabel(Index:Integer): TQRLabel; > > property MyLabels[Index: Integer]: TQRLabel read GetMyLabel; > default; > These two under Public Declarations?
i'd make GetMyLabel Protected or Private and property Mylabels Public. Probably it doesn't much matter because you're not going to access the property from outside the form anyway. > > > > function GetMyLabel(Index:Integer):TQRLabel; > > begin > > // in production probably should do some error checking ... > > return FindComponent(format('mylabel_%d',[Index]); > > end; > This under Implementation correct > Should it be "result := [...] oops - yes it should. (i've been writing C++ - i knew something would creep in). > Should it be " [...] MyLabels.FindComponent ...etc"? no. FindComponent searches the component list by name. So you want to call the FindComponent method of the owner of your QRLabels. This is the TForm. > I get error "Undeclared identifier - MyLabels" > If I leave MyLabels out I get error Undeclared identifier - > FindComponent. > > I can see how FindComponent would work - I'm just tripped up on the > declaration details, I think. see above. I regret winging this - it's too confusing. Here is a revised version of the functions (that DO compile and even work) which should be a lot clearer. Also, I've posted the full .pas and .dfm files here http://roserox.co.th/dugnz/unit2.pas http://roserox.co.th/dugnz/unit2.dfm function TForm2.GetMyLabel(Index: Integer): TQRLabel; var ret:TQRLabel; begin // in production probably should do some error checking ... result:= FindComponent(format('qrlabel_%d',[Index])) as TQRLabel; end; procedure TForm2.Button1Click(Sender: TObject); var i:integer; begin for i:=1 to 2 do mylabels[i].caption:='foo'; end; The QReport in this demo program has two labels on it - QRLabel_1 and QR_Label_2 -ns --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/