How to break a label line automatically?

Asked

Viewed 8,336 times

1

= .NET Framework 4.0
= Visual C#

I have a problem with Labels, when I assign a value to the property text and this value is very large, it "breaks" its container, going beyond the edges, with this, the part that is outside the limits is not possible to be seen. What I’m looking for is a solution to this, break the text automatically (from space, do not break the word) when it reaches 5 pixels from the right edge, however, I have no idea how to do it.

I’ve thought about disabling the property AutoSize, but it is not feasible, because the height of the text is also limited.

1 answer

8


You might be doing something like this:

label1.MaximumSize = new Size(100, 0);
label1.AutoSize = true;
label1.Text = "Stack Overflow em Portugues";

The result will be:

Fonte

Browser other questions tagged

You are not signed in. Login or sign up in order to post.