The Label Control (TLabel)

Hierarchy: TObject - TPersistent - TComponent - TControl - TGraphicControl - TCustomLabel - TLabel

This control places a label on a form. The contents of labels can be manipulated in a program to produce simple reports. The Additional palette provides the LabelEdit control as a quicker way of adding Edit boxes with a label attached.

Properties

The main properties are: Caption, Color, Cursor, Enabled, Font.

FocusControl

A Label can have an accelerator key, created by inserting an '&' in front of the desired letter. You can then designate the control on the form that will receive control when the accelerator key is pressed. For example, you may designate a Memo or an EditBox as the FocusControl of a particular label, in which case pressing the accelerator key will allow the user to set the focus on that control.

Example

In this example from the Hospital Equipment project the contents of labels are changed in program code to provide a dynamic report:

form10.Label2.Caption:=patientlastname + ', ' + patientfirstname;
form10.Label10.Caption:=wardnumber;
form10.Label12.Caption:=patientaddress1;
form10.Label13.Caption:=patientaddress2;

When combined with a file this can produce a 'mail merge' similar to that found in Office products.

Back to Tutorial

Back to Palette List