procedure TForm1.AddAComponent(A: TComponent); var b : Integer; begin for b := 0 to TreeView1.Items.Count-1 do if TreeView1.Items[b].Text = A.Name then exit; if A.HasParent then AddAComponent(A.GetParentComponent); for b := 0 to TreeView1.Items.Count-1 do if TreeView1.Items[b].Text = A.GetParentComponent.Name then TreeView1.Items.AddChild(TreeView1.Items[b],A.Name); end;
procedure TForm1.FormCreate(Sender: TObject); var a : Integer; begin TreeView1.Items.Add(TreeView1.Selected,Name); For a := 0 to ComponentCount-1 do AddAComponent(Components[a]); end; |