I have a method that sets the text for a label, and I'd like to use it to display several lines of text. Is it possible to insert a character into the text for the label to do this?
When you click on the label Text property in the Property window for the label, a drop down will appear in which you can, when you press Enter , go to the new line.
You can also use <br/> where you want to break the text.
The \n character matches newline characters.
Newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in a character encoding specification (e.g., ASCII, EBCDIC) that is used to signify the end of a line of text and the start of a new one.
You have a few choices. If you can trust your callers, you can allow formatted text to be passed into the parameter (so someone can pass "<br />" as part of the label text. If you can slightly trust them, you can still allow that one particular piece of HTML to come through while disallowing others, but you might want to put the intelligence in your function to limit how many breaks can come in one label.
Another (more obscure) choice would be to designate some other character or sequence of characters that you know will never appear on a label to indicate a break (e.g. "#NEWLINE"), and have the function substitute "<br />" wherever that occurs.
Normally a simple <br/>
tag will do it!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With