How to have long Strings in Labels, on multiple lines.

Hi guys,

I’ve a label with a long string and the part going outside its container is truncated.

I notice that the label splits on multiple line if I set the width in pixels
label.setWidth(“500px”);

But if I set the width in %, it does not display on multiple lines.
label.setWidth(“100%”);

I use the container at different places and the container has a different width each time.
The label should take 100% of the width of its container.

Is there a simple way to say “take multiple lines” to a label having its width = 100% ?

Many thanks.
John.

Hi,

have you tried “word-wrap: break-word !important;” or “white-space: normal;” in CSS to force text to break on multiple lines. I am not sure about the difference, but if i recall correctly, either one should do the trick :slight_smile:

Toni

You shouldn’t need to do anything in CSS in order to make the text wrap, if your Label has a specified width. Only undefined width labels are forced on one line.

If this is not the case, there might be some bug/regression in 6.0.1 (if that’s the version you’re using).

With a simple test case, I don’t see any problem with multiple lines:
http://uilder.virtuallypreinstalled.com/run/labeltest/

Yes, I tested with the two scenarios where the size of a container is set and the label is 100% (default) and undefined. The undefined size seems to cause the label not to wrap according to container.

http://uilder.virtuallypreinstalled.com/run/label_in_panel/

You are completely right, guys!

The container of the container of the container of the label had an undefined size.

Thank you and sorry for your time.

By the way, uilder.virtuallypreinstalled.com is a terrific idea!