1

A label displays a long string (letters and slashes, no spaces) in multiple lines. I want to control where possible line wraps should happen. Specifically after slashes wraps are desirable, whereas in other places not. I tried appending a zero-width space (unicode U+200B ZERO WIDTH SPACE) after each slash, but the label ignores these when determining the line wraps. Adding regular spaces results in the correct wrapping, but the spaces should not be visible.

Example how it looks:

This/is/a/long/tex
t/without/spaces/a
nd/wrong/wrapping

This is how it should look

This/is/a/long/
text/without/
spaces/and/wrong/
wrapping

Is it possible to add invisible wrap hints in a Winforms Label?

cad
  • 347
  • 5
  • 20
  • Maybe try `label3.Text = "This/is/a/long/" + Environment.NewLine + "text/without/"; ` Something like this? – 高鵬翔 Dec 15 '20 at 08:36
  • The text can change and for inserting manual linebreaks I'd need to calculate the rendered text width. I'd like to have a solution that works like the wrapping with spaces. – cad Dec 15 '20 at 16:09

0 Answers0