HappyCoding
HappyCoding

Reputation: 661

What must I set so that the label text will wordwrap respective to the parent panel's width?

I'm using C++ Builder.

I have created a panel and set the width of said panel to 350.

I am using the following code to create labels.

TLabel* tempLabel = new TLabel(this);
tempLabel->Parent = Panel6;
tempLabel->Caption = temp->Text;
tempLabel->Top = 25*i;
tempLabel->Font->Style = TFontStyles() << fsBold;
tempLabel->Font->Color = clRed;

TLabel* tempLabel2 = new TLabel(this);
tempLabel2->Parent = Panel6;
tempLabel2->Caption = temp->Title;
tempLabel2->Top = tempLabel->Top + 10;
tempLabel2->AutoSize = true;
tempLabel2->WordWrap = true;

TLabel* tempLabel3 = new TLabel(this);
tempLabel3->Parent = Panel6;
tempLabel3->Caption = temp->Message;
tempLabel3->Top = tempLabel2->Top + 10;
tempLabel3->AutoSize = true;
tempLabel3->WordWrap = true;

The result is that the captions of tempLabel2 and tempLabel3 are extending passed the 350 width of the containing panel. I have read online about setting AutoSize to true and WordWrap to true. This attempt was not successful.

What must I set so that the label text will wordwrap respective to the parent panel's width?

Upvotes: 0

Views: 418

Answers (0)

Related Questions