January 30th, 2015

How to break lines and format labels

If you have ever needed to put a line break into the text of a BiLabel you have probably experienced that a simple \n character doesn’t work. In this post I will show you a couple of ways you can use to control the formatting of your labels.
First let’s examine the label.

You can either put the text into the text property:

text in property

or inside the tag:

text in tag

In the last example, where the text is put into the tag, you can get a line break simply by pressing Enter in your code, like this:

line break in tag

So far, we have been using the ”text” property of the BiLabel to give it simple text, however, we can also enter fully formatted HTML code via the HTML property, like this:

block quotes

Since I had to escape the < and > characters it looks a bit messy. Obviously, if you just called setHtml from JavaScript you wouldn’t have to escape those characters like that; However, since we are now in markup land, we have to do it. If the HTML code was slightly more complicated we would need an even better way to write our HTML.

The trick is to use namespace to have nicely formatted XHTML right inside the markup, that is inside the tag.

First, let’s declare the namespace in the application tag:


Then, we can use it like this:

xhtml label code

The result of the above code would look like this:

xhtml result

Good luck and enjoy your formatting!

4 Responses to 'How to break lines and format labels'

  1. 1neo
    November 12th, 2010 at 1:37 am

    is it the correct way to do

  2. 2Sergey G.
    December 8th, 2010 at 2:25 am

    A very useful new information.
    Does it works in version 3.0?

  3. 3Ran
    December 10th, 2010 at 8:50 am

    Yes it works in Bindows 3.0. It’s been in Bindows since 1.3 or something maybe even earlier.

  4. 4Codebix.com
    October 1st, 2011 at 6:59 pm

    Codebix.com - Your post is on Codebix.com…

    This post has been featured on Codebix.com. The place to find latest articles on programming. Click on the url to reach your post’s page….

Leave a Response

Imhotep theme designed by Chris Lin. Proudly powered by Wordpress.
XHTML | CSS | RSS | Comments RSS