Board index » delphi » FindComponent: need a little help

FindComponent: need a little help

I don't think I'm really understanding the concept of this function, but
I've followed examples that I found in GG's.

I have a TButton on my form called "xy".

When I used...

With FindComponent('xy') DO

I get a reference to form itself, when I actually want a reference to the
button.

In the examples that I read, they were definitely talking about referencing
controls on the form and not the form itself.

Thank You,

Lee

 

Re:FindComponent: need a little help


I cast the result to TButton and it works, but I think the thing that was
throwing my was that when I was stepping through the code, placing the
cursor over say "Caption" defaults to the form's information for some
reason.

Lee

Re:FindComponent: need a little help


Quote
"Lee Jenkins" <lee_jenkin...@datatrakpos.com> wrote in message

news:cjqW7.109181$RE3.20523309@typhoon.southeast.rr.com...

Quote
> I cast the result to TButton and it works, but I think the thing that was
> throwing my was that when I was stepping through the code, placing the
> cursor over say "Caption" defaults to the form's information for some
> reason.

With FindComponent('xy') DO  caption:='X';

no caption for a TComponent -> only Caption available is self.caption

with TButton(FindComponent('xy')) DO  caption:='X';

when app not executing the IDE correctly identifies the cast
but buggsy-d-{*word*81} seems to ignore the 'With' and cast

'with' doubt? move it out  ! ;-)

buggsy does indicate correctly using the form
var t:tcomponent;
t:=findcomponent('BitBtn1');
Tbitbtn(T).caption:='Y';

Re:FindComponent: need a little help


Thank you.

Lee

Other Threads