When speaking of the object’s "son", there are two possible interpretations:
1) The object is a Tcomponent and Owner of your children, which can be accessed by the Components property. For example:
for i := 0 to Form1.ComponentCount - 1 do
if Form1.Components[i] is TLabel then
TLabel(Form1.Components[i]).Caption := IntToStr(i);
2) The object is a Tcontrol and Parent of your children, which can be accessed by the Controls property. For example:
for i := 0 to Panel1.ControlCount - 1 do
if Panel1.Controls[i] is TLable then
TLabel(Panel1.Controls[i]).Caption := IntToStr(i);
Generally the Form is the Owner of all components and the visual controls that contain other controls (when moving the parent the children go together) are the parents of their children.
+1, and if you know the name of Trectangle, ie if it is a visible object in the design, you can take the shortcut:
NomeRectangle.FindComponent('nome do TLabel');
– Junior Moreira
@Júniormoreira well remembered
– Jefferson Rudolf
Wouldn’t you be able to do the direct access without having to search? for example Trectangle.Children[0]." Sticky Component"(Tlabel). Color etc etc.
– tempoDeveloper