[Overview][Constants][Types][Classes][Procedures and functions][Index] Reference for unit 'StdCtrls' (#lcl)

TLabel.Caption

The text displayed for the control.

Declaration

Source position: stdctrls.pp line 1626

published property TLabel.Caption : TCaption;

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.

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

TLabel.ShowAccelChar

  

Underlines the character in the label that acts as the accelerator or short cut key.

TLabel.FocusControl

  

The control associated with the label and its accelerator key (AccelChar).

TLabel.Color

  

Contains the color used for the background on the control.

TLabel.Font

  

The font to be used for text display in this control.

TLabel.Layout

  

Vertical alignment for control text (at the top, bottom, or center).

TControl.Caption

  

The text displayed for the control.


Version 3.2 Generated 2024-02-25 Home