Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread FindComponent problem
Mon, Aug 19 2019 6:25 PMPermanent Link

KimHJ

Comca Systems, Inc

I have a form with TCaptionPanel's when I try to set the caption after using FindComponent I get an error:

Unable to get property 'tcaptionpanel_setcaption of undefined or null reference

TCaptionPanel(FindComponent('Item' + IntToStr(i))).Caption := MyText;


The TCaptionPanel do have property called Caption;

I tried other properties and I get an error on all of them.

Thanks,
Kim
Tue, Aug 20 2019 5:11 AMPermanent Link

Matthew Jones

KimHJ wrote:

> 'tcaptionpanel_setcaption of undefined or null reference

The FindComponent is returning null, so the component might not exist. I think the name of components is not necessarily set - a while since I dug into that. You'd be better off keeping an array of objects and keep references to the components IMO.

--

Matthew Jones
Tue, Aug 20 2019 7:15 AMPermanent Link

Uli Becker

Kim,

> I have a form with TCaptionPanel's when I try to set the caption after using FindComponent I get an error:
> Unable to get property 'tcaptionpanel_setcaption of undefined or null reference

Try to specify the container control, e.g.:

TCaptionPanel(<CaptionPanelParentControl>.FindComponent('Item' + IntToStr(i))).Caption := MyText;

Uli
Tue, Aug 20 2019 9:42 PMPermanent Link

KimHJ

Comca Systems, Inc

Uli Becker wrote:

>Try to specify the container control, e.g.:

>TCaptionPanel(<CaptionPanelParentControl>.FindComponent('Item' + IntToStr(i))).Caption := MyText;

Thanks Uli, that did it.

Kim
Image