From RAD Studio API Documentation
Jump to: navigation, search


property Parent: TWinControl read FParent write SetParent;


__property TWinControl* Parent = {read=FParent, write=SetParent};


Type Visibility Source Unit Parent
property public
Vcl.Controls TControl


Specifies the parent of the control.

Use the Parent property to get or set the parent of the control. The parent of a control is the control that contains it. For example, if an application includes three radio buttons in a group box, the group box is the parent of the three radio buttons, and the radio buttons are the child controls of the group box.

To serve as a parent, a control must be an instance of a TWinControl descendant.

When creating a new control at run time, assign a Parent property value for the new control. Usually, this is a form, panel, group box, or a control that is designed to contain another. Changing the parent of a control moves the control onscreen so that it is displayed within the new parent. When the parent control moves, the child moves with the parent.

Some controls (such as ActiveX controls) are contained in native windows rather than in a parent VCL control. For these controls, the value of Parent is nil (Delphi) or NULL (C++) and the ParentWindow property specifies the window.

Note: The Parent property declared in TControl is similar to the Owner property declared in TComponent, in that the Parent of a control frees the control just as the Owner of a component frees that component. However, the Parent of a control is always a windowed control that visually contains the control, and is responsible for writing the control to a stream when the form is saved. The Owner of a component is the component that was passed as a parameter in the constructor and, if assigned, initiates the process of saving all objects (including the control and its parent) when the form is saved.

See Also

Code Examples