Board index » cppbuilder » Creating Labels at runtime

Creating Labels at runtime

Hello,

I want to add labels to a form at runtime.

I declare a pointer to a TLabel object as follows:-

TLabel *TestLabel;

Then, in the constructor of the main form, I instantiate a TLabel object and
set Left,Top etc properties :-

TestLabel=new TLabel(Owner);

TestLabel->Top=.....  etc etc.

Then, In the FormShow method of the main window :-

TestLabel->Show();

It doesn't show.    Any suggestions?

Thanks

Neil.

 

Re:Creating Labels at runtime


Quote
Neil Lloyd wrote:
> TestLabel=new TLabel(Owner);
> TestLabel->Top=.....  etc etc.
> It doesn't show.    Any suggestions?

For future reference, component-related questions are better asked in the .vcl.components.using
newgroup.

Now, you should set the Parent property of the label as the form:
   TestLabel->Parent = this;

Adam.

Re:Creating Labels at runtime


Quote

>It doesn't show.    Any suggestions?

TestLabel->Parent=Owner;

Other Threads