parent

Type: Window

Availability: Assigned by Painter at development time, read or write at run time

The parent property of the Control class contains a reference to the direct parent of the control. This direct parent is either the form or another control. This property returns the object of the parent form or control. Using this object can then access the properties of a window. If the parent of the control is the form, the parent is the same object as that returned by the form property of the control.

At run time, if the control has an associated window (the normal runtime control situation), the parent can be changed only to another form or control with an associated window. Changing the parent at run time by using this property is not recommended. The following example finds all direct children of Frame1 and makes them invisible.

vars
    ctl  : Control;
    indx : Integer;
begin
    foreach indx in 1 to controlCount do
        ctl := controls(indx);
        if ctl.parent = frame1 then
            ctl.visible := false;
        endif;
    endforeach;
end;