TextBlock

The TextBlock control allows you to put text on the screen as an alternative to the Label control. Typically, the Label control is used is for short, one-line text (and sometimes images), while the TextBlock is used for multi-line strings and is a text-only control.

TextBlocks are ideal if you need to provide detailed instructions, error or warning messages to the user, however they should not be over-used.

Note that a TextBlock is not editable at runtime. It is simply a multi-line rich text label. To create an editable TextBox, see TextBox.

Properties

The key properties of a TextBlock include:

  • Text. The editable text you want to display.
  • TextWrapping. Whether to wrap the text.
    • No Wrap
    • Wrap (and hyphenate a word that extends beyond the boundary of the control).
    • Wrap with Overflow (extend the text beyond the boundary of the control to accommodate, rather than hyphenate, the word that doesn’t fit.)
  • TextAlignment. Set the (Left, Centre, Right, Justify) alignment of the text.

Scripting Syntax

The properties of a control include events. Scripts can be used to set the properties of a control or be used to trigger an action associated with an event. For a TextBlock:

  • The contents of a TextBlock is the text to be displayed in the form. To add text to the TextBlock programmatically use the following syntax:
  • TextBlock1.Text = ‘The text to show.’

Create a TextBlock