UserGuide

Mobile Label

From Xojo Documentation

The label control displays text on the screen. This is often used for displaying information or providing labels to other controls.

Below are commonly used properties. Refer to MobileLabel in the Language Reference for the complete list.

Properties

LineBreakMode - Uses the LineBreakModes enumeration to indicate how text will wrap (or be truncated) when it is too long to fit in the label.

Text - This is the text that appears in the label.

Alignment, TextColor, TextFont - These properties change the alignment, color and size of the text.

Visible - A boolean that indicates if the Label is visible when your app runs.

Usage

Generally you will like set up the text for your labels using the Inspector. But you can also set the text using code:

NameLabel.Text = "Enter your name:"

You may have situations where the label should not yet be visible. You can set its Visible property to OFF in the Inspector and then turn it on in your app when appropriate:

If showName Then
NameLabel.Visible = True
End If

Labels are will automatically show multiple lines for lengthy text if you increase the height. By default the text wraps using word wrapping. But you can change the LineBreakMode property to use any of these methods for wrapping and/or truncating:

  • WordWrap (default): Words are not split when text wraps to a new line.
  • CharacterWrap: Words may be split whe text wraps to a new line.
  • Clip: Text is clipped at the end, possibly mid-character.
  • TruncateStart: Ellipses appear at the beginning of the text if it cannot all fit.
  • TruncateEnd: Ellipses appear at the end of the text if it cannot all fit.
  • TruncateMiddle: Ellipses appear in the middle of the text if it cannot all fit.

Refer to the MobileLabel.LineBreakModes enumeration for more details on these values.

Changing the formatting of a label is done using the Alignment, TextColor and TextFont properties. Alignment can be Left, Center, Right, Justified and Natural. To change the alignment you use the MobileTextControl.Alignments enumeration. This centers the text in the label:

NameLabel.Alignment = MobileTextControl.Alignments.Center

You can set the color to be any Color with the TextColor property:

NameLabel.TextColor = Color.Blue

To change the font, you use the TextFont property in conjunction with the Font class.

See Also

MobileLabel, Font classes