Skip to main content

Justify Text in a Text Box

Overview

If you need to change the justification on a field from a defaulted left justification to right justification, try the method outlined here.

Details

The TTierEdit control is the standard control for the text input and other user-entered data. Unfortunately, this control does not allow for the designer to right-justify the text entered in this field, but instead defaults to left justification. A workaround for this limitation is to use the TTierMemo control.

Steps

  1. Place a TTierMemo within your form design.

tier_justifytext.png

  1. Use the sizing handles to size the memo as you would a TTierEdit.
  2. In the Object Inspector, turn off the scroll bars.
  3. Set the alignment of the field to taRightJustify.
  4. Enter a field name and field size and, most important, change the field type from MEMO to STRING.
  5. In the Object Inspector, set the max size to the same size as the field size in order to avoid truncation.
  6. Save the form to complete the process. This field will now appear right-justified to the user on the form and it will be stored in the database as a VARCHAR with the length you defined on the field size.

There are two limitations to using the TTierMemo in this way:

  • There is no calculation option in the Object Inspector so input for this field cannot come from a calculation.
  • There is no 'hide on validation' option in the Object Inspector so this object cannot be directly hidden or shown based on validation results. The 'hide on validation' limitation can be overcome by utilizing a TTierEdit that is set to hide on validation (and colored the same as the form background) and placed over the TTierMemo in order to effectively hide it until the validation is correct.