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

TControl.Parent

The control within which the control is shown.

Declaration

Source position: controls.pp line 1822

public property TControl.Parent : TWinControl
  read FParent
  write SetParent;

Description

When the Parent moves or hides, all its children move or hide together with it.

Every TControl must have a Parent, else it is never shown.

The Parent of a floating form is Nil.

Set the parent last to reduce updates. For example:

Button1 := TButton.Create(Self);
Button1.Name := 'Button1';
Button1.Caption := 'Click me'; // parent is not set, so it does not update the whole form
Button1.Parent := Form1; // set parent as last, the LCL now applies all properties

Delphi/VCL: Parent must be set first under Delphi, because many properties work differently if they are set before or after Handle creation. The LCL applies the properties when the Handle is created.


Version 3.2 Generated 2024-02-25 Home