Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help,runtime TLabel component Doesn't show

Status
Not open for further replies.

samibami

Programmer
Oct 12, 2003
28
0
0
IL
hi there,

i need to create a TLAbel component at runtime on onButtonClick event (actually a few TLables).
when a button is pressed you would see between 4 to 5 TLAbels on the form.

i tried the following code:

for(some condition )
{
TLabel *MyLabel = new TLabel(this);
MyLabel->Enabled=true;
MyLabel->Caption=SKey.Segment;
MyLabel->Left=16+somthing;
MyLabel->Top=80;
MyLabel->Visible=true;

}

can you tell me why this is wrong? why can't i see the new TLabels?

please help...10x
 

it's me again...

i forgot to mention that the code i wrote before only deals with one TLabel! that's because i couldn't find a way to create an array of TLabels* (is it even possible?)and initialize them with a loop.

so ,do you know any other way to do that?

10x again
 


o.k, i found the answer!

in order to create a TLabel component on runtime use the following code : TLable *MyLabel=new TLabel(this);

if you want it to show on your form , you must set the "parent" property according to whom is the parent.
int my case the parent was a groupBox1 so the code was:

MyLabel->Parent=groupBox1;

it all depends where you want the Label to show!
don't forget to set visibilty and enable the label itself.

now will someone tell me why cant i do the follwing code:

TLabel *LabelArray[count]; //here "count" is dynamicly set!

if i replace "count" with a const number it works!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top