Sign in Join
FPDoc Onlineexperiment

TLabel.Caption property

Member of TLabelpublishedIn unit StdCtrls

The text displayed for the control.

Declaration

pascal
property Caption:;

Description

Caption is a TCaption property with the text displayed for the control. By default, Caption has the same value as the Name property used for the control. An explicit value can be assigned at design-time using the Object Inspector, or by the developer in program code.

Caption can be used to display an accelerator (or shortcut) key which allows an associated control to be given focus or executed. The shortcut key is identified by placing an Ampersand (&) character in front of the character used as the accelerator key. Use two Ampersand characters to display a single Ampersand which is not a shortcut key. Note that the accelerator character is not displayed when the label is rotated.

Set ShowAccelChar to False to disable display and use of the accelerator key in the control. This also allows Caption to display an Ampersand (&) character without escaping its value.

Use FocusControl to specify the control which is focused/activated when the accelerator key is detected and ShowAccelerator is enabled.

Set values in Font to specify the typeface, size, color, and style used to display the Caption text. Use Color to set the background color for the control.

For example:

{
var
  ALabel: TLabel;
  Form1: TForm;
  Memo1: TMemo;
}

ALabel.ShowAccelerator := True;
ALabel.FocusControl := Memo1;
ALabel.Caption := '&Notes && Comments';

Displays the 'N' character with an underline indicating the accelerator key. Pressing Alt+N activates the shortcut key and causes the associated TMemo control to be given focus.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.