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

# TCustomLabeledEdit

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Defines an edit control with a label bound to the control.

## Declaration

Source position: extctrls.pp line 1024

`type TCustomLabeledEdit = class(TCustomEdit)`
`protected`
`class procedure WSRegisterClass; override;` |  | Registers this component class with the current WidgetSet.
`procedure SetParent(); override;` |  | Sets the value for the Parent property.
`procedure SetName(); override;` |  | Sets the value for the Name property and the Caption in the label.
`procedure Loaded; override;` |  | Performs actions needed when the component has finished loading in the LCL streaming mechanism.
`procedure DoPositionLabel; virtual;` |  | DoPositionLabel - perform the code for positioning the label.
`procedure Notification(); override;` |  | Handles a notification when a component is added to or removed from the control.
`procedure CMBiDiModeChanged(); message;` |  | Handles the CM_BIDIMODECHANGED control message for the control.
`procedure CMVisibleChanged(); message;` |  | Handles Focus changes, and forces UpdateControlState.
`procedure CMEnabledChanged(); message;` |  | Handler signalled when the Enabled property has been changed.
`procedure CreateInternalLabel; virtual;` |  | CreateInternalLabel - method for internally creating label.
`public`
`constructor Create(); override;` |  | Constructor for the class instance.
`property EditLabel: TBoundLabel; [r]` |  | EditLabel - the label attached to the edit box.
`property LabelPosition: TLabelPosition; [rw]` |  | Edge on the edge control where the bound label is aligned.
`property LabelSpacing: Integer; [rw]` |  | Number of pixels between the control and its bound label.
`end;`

## Inheritance

`TCustomLabeledEdit` |  | Defines an edit control with a label bound to the control.
`TCustomEdit` |  | The base class for controls presenting editable text.
`TWinControl` |  | Implements a windowed control which can contain other child controls.
`TControl` |  | The base class for visible controls.
`TLCLComponent` |  | The base class for LCL components which have an associated widget.
`TComponent`
?
`TObject`

## Description

TCustomLabeledEdit is a TCustomEdit descendant which defines an edit control with a label bound to the control. TCustomLabeledEdit is the base type for TLabeledEdit.

Note particularly the EditLabel property (see TBoundLabel), which contains the label attached to the Edit control.

Use LabelPosition to specify the location where EditLabel is displayed relative to the edit box in the control. Use LabelSpacing to set the spacing between EditLabel and the edit control.

About TCustomLabeledEdit / TLabeledEdit

TCustomLabeledEdit and TLabeledEdit are based on the similarly named controls from the Delphi VCL. While they offer code compatibility with the VCL class, they have some drawbacks when used in the LCL. For instance:

- They do not work very well with the positioning and anchoring mechanisms used in LCL. They do not have an Align property used to position, align, and stack controls towards one of the edges on the parent control.
- There are also shortcomings when using BorderSpacing; the extra spacing is inserted between the bound label and the edit box on the control instead around the composite control.
- Labels with long captions are not ellipsified or aligned properly when longer than the associated edit control.
- Multi-line captions on a label are not positioned as expected; the label often overlaps (or is obscured by) adjacent controls.
- When EditLabel is placed above or below the Edit control, and its caption is wider than the Edit, the text will be clipped at the Edit's left/right sides. Likewise, when the EditLabel is placed at the left or right of the Edit control and is taller than the Edit, it will be clipped at the top and bottom edges of the Edit control.

Despite the convenience of TCustomLabeledEdit / TLabeledEdit, most will elect to use separate label and edit controls to avoid the shortcomings in the align and anchoring mechanisms for the composite control.

## See also

TCustomLabeledEdit.EditLabel |  | EditLabel - the label attached to the edit box.
TCustomLabeledEdit.LabelPosition |  | Edge on the edge control where the bound label is aligned.
TCustomLabeledEdit.LabelSpacing |  | Number of pixels between the control and its bound label.
TBoundLabel |  | Implements a label bound to another control.
TLabelPosition |  | Specifies the position for a label relative to an associated control.
TCustomEdit |  | The base class for controls presenting editable text.
TCustomLabel |  | Control used to show static text optionally using multiple lines.