23

How do I extend the text in a Windows Forms CheckBox to more than one line?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kenny C
  • 2,279
  • 1
  • 19
  • 20

2 Answers2

24

You need to use \r\n in order to add a new line. You might have to do this in the code behind. So your code would be like this:

myLabel.Text = "New\r\nLine\r\nExample";
keyboardP
  • 68,824
  • 13
  • 156
  • 205
  • Thanks, this works. And you're right it only works in code not in the designer – Kenny C May 09 '11 at 13:51
  • 23
    You can use the designer: click the drop-down arrow on the right hand edge of the Text line to get the multi-line text editor – stuartd May 09 '11 at 14:19
  • There is no more drop-down arrow in VS 2017. I've found strange behavior in the Designer. Setting AutoSize to: False did nothing. Only after I've changed "AutoEllipsis" to different value (from True to False or vice versa) it started working as multiline. – Krzysiek Apr 24 '21 at 15:48
11

First you should turn autosize property to False. Then resize the box and use \r\n for going to next line.

MReza
  • 152
  • 1
  • 7
  • 1
    No need to have AutoSize to False, no need for escaped characters... if you're using the forms editor then do it directly using the drop-down arrow on the right of the text field – Pedro Ferreira Jul 23 '19 at 17:00