MyString := TControl(Sender).Name
or
MyString := TButton(Sender).Name;
cheers, Eduardo
"Calabetta" <nos...@no-optec-srl.com> escreveu na mensagem
news:3edf324d$1...@newsgroups.borland.com...
Once Sender is usually TObject and TObject doesn't have a Name property,
you must typecast Sender like
MyString := TControl(Sender).Name
or
MyString := TButton(Sender).Name;
cheers, Eduardo
"Calabetta" <nos...@no-optec-srl.com> escreveu na mensagem
news:3edf324d$1...@newsgroups.borland.com...
Or to be a little safer, I might use some checking first:
If Sender is TControl
then MyString := TControl(Sender).Name
else raise ...
Regards, JohnH
The Name property is introduced in TComponent, so typecasting to TComponent
will suffice. Note however that the Name property's main purpose is to be
used at design time, not to be messed around with at run-time.
Regards
Magnus Oskarsson
if Sender is TComponent then
MyString := TComponent(sender).Name
else
MyString := 'not a TComponent';
Jens
--
____________________________________________________________
email (delete all digits, please): in...@11.jensberke.11.de
Or, to be even more generic, use RTTI. <g>
--
Woody (TMW)
"Start every day off with a smile and get it over with."
-- W. C. Fields
You are right about the use of the Name property at design time, however,
I have used it many times at run time. Not to change the name, but to
determine which controls, of the same type, I am dealing with. I have also
used the tag property for this, but the name works just fine also.
Edwin