Board index » cppbuilder » Accessing Component Name

Accessing Component Name


2005-02-18 12:55:27 AM
cppbuilder16
Is there a way to access the components name? I have a TLabel that is a
part of my component and I would like the defualt caption of the TLabel
to be the name given to the component. I've tried to do stuff like
"MyLabel->Caption = this->Name" or "MyLabel->Caption = Name" in the
constructor and in the After Construction function but to no avail.
Anyone know how to do this or can it be done?
Shannon
 
 

Re:Accessing Component Name

Shannon Peterson wrote:
Quote
Is there a way to access the components name? I have a TLabel that is a
part of my component and I would like the defualt caption of the TLabel
to be the name given to the component. I've tried to do stuff like
"MyLabel->Caption = this->Name" or "MyLabel->Caption = Name" in the
constructor and in the After Construction function but to no avail.
MyLabel->Caption = MyLabel->Name;
this is the TForm, I guess.
 

Re:Accessing Component Name

No the Actual Component being created is TCustomControl and I want to
set the TLabel->Caption in the Actual Component to the Actual Components
Name property.
OBones wrote:
Quote
Shannon Peterson wrote:

>Is there a way to access the components name? I have a TLabel that is
>a part of my component and I would like the defualt caption of the
>TLabel to be the name given to the component. I've tried to do stuff
>like "MyLabel->Caption = this->Name" or "MyLabel->Caption = Name" in
>the constructor and in the After Construction function but to no avail.


MyLabel->Caption = MyLabel->Name;

this is the TForm, I guess.
 

{smallsort}

Re:Accessing Component Name

Try setting it in either AfterConstruction() or in Loaded(). Both are
virtual methods so be sure to call the inherited method also.
Not sure if the name is available in AfterConstruction but it won't take
long to test.
--
Malcolm Smith
MJ Freelancing
www.mjfreelancing.com
Borland Technology Partner
Contributing Editor
C++Builder Developers Journal
bcbjournal.org
"Shannon Peterson" < XXXX@XXXXX.COM >wrote in message
Quote
No the Actual Component being created is TCustomControl and I want to
set the TLabel->Caption in the Actual Component to the Actual Components
Name property.

OBones wrote:

>Shannon Peterson wrote:
>
>>Is there a way to access the components name? I have a TLabel that is
>>a part of my component and I would like the defualt caption of the
>>TLabel to be the name given to the component. I've tried to do stuff
>>like "MyLabel->Caption = this->Name" or "MyLabel->Caption = Name" in
>>the constructor and in the After Construction function but to no avail.
>
>
>MyLabel->Caption = MyLabel->Name;
>
>this is the TForm, I guess.