Labels

From RAD Studio
Jump to: navigation, search

Go Up to Text Controls


Labels display text and are usually placed next to other controls.

Use this component: When you want users to do this:

Vcl.StdCtrls.TLabel

Display text on a nonwindowed control.

Vcl.StdCtrls.TStaticText

Display text on a windowed control.



You place a label on a form when you need to identify or annotate another component such as an edit box or when you want to include text on a form. The standard label component, TLabel, is a non-windowed control, so it cannot receive focus; when you need a label with a window handle, use TStaticText instead.

Label properties include the following:

  • Caption contains the text string for the label.
  • Font, Color, and other properties determine the appearance of the label. Each label can use only one typeface, size, and color.
  • FocusControl links the label to another control on the form. If Caption includes an accelerator key, the control specified by FocusControl receives focus when the user presses the accelerator key.
  • ShowAccelChar determines whether the label can display an underlined accelerator character. If ShowAccelChar is True, any character preceded by an ampersand (&) appears underlined and enables an accelerator key.
  • Transparent determines whether items under the label (such as graphics) are visible.

Note: The Color of a TLabel is always the color of the background unless you set TLabel.Transparent to false.

Labels usually display read-only static text that cannot be changed by the application user. The application can change the text while it is executing by assigning a new value to the Caption property. To add a text object to a form that a user can scroll or edit, use TEdit.

See Also