GetTabControlList (Delphi)
Description
This example uses the GetTabControlList method to display the number and names of the controls owned by a form. To test the method, build a VCL Form Application, and add to the form: a button, a memo, and an edit box from the Tool Palette. Add the method below to the OnClick event of the button. The number of the controls owned by TForm1 is displayed in the edit box, and the name of each control is displayed in the memo. Only child controls are displayed, and not the controls owned by the child. You can add any other controls on the form to test this. This method can also be used on other TWinControl components.
Code
procedure TForm1.Button1Click(Sender: TObject);
var
list1: Tlist;//controls list
I: Integer;
Control: TWinControl;
begin
List1 := TList.Create;//creates the list
Form1.GetTabControlList(List1);//adds the controls
Edit1.Text:=IntToStr(List1.Count);
for i := 0 to list1.Count-1 do
begin
Control := TWinControl(List1[I]);
Memo1.Text:= Memo1.Text+#13#10+Control.Name;
end;
end;