• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

List of Component Names

Hi all,

Say for instance I have 4 Panels, and there are 5 Textboxes on each panel, how can I have a dropdown box on the actual form, with the Names for all 20 Textboxes.

eg. Textbox1,
    Textbox2, ... etc.

Thanks

Pieter
0
PieterJ
Asked:
PieterJ
  • 2
  • 2
1 Solution
 
kretzschmarCommented:
iterate through the forms components like

for i := 0 to componentcount-1 do
  listbox1.add(components[i].name);

maybe you need only special components then

for i := 0 to componentcount-1 do
  if components[i] is tedit then
    listbox1.add(components[i].name);

working just from head (syntax errors possible)

meikl ;-)
0
 
raidosCommented:
Procedure GetComponents(Parent: TComponent; Const List: TStrings);
Var
  Loop : Integer;
begin
  For Loop := 0 To Parent.ComponentCount-1 do Begin
    List.Add(Parent.Components[Loop].Name);
    If Parent.Components[Loop].ComponentCount > 0 Then
      GetComponents(Parent.Components[Loop], List);
  End;
End;

procedure TForm1.Button1Click(Sender: TObject);
Begin
  Combobox1.Clear;
  GetComponents(Form1,ComboBox1.Items);
end;

This will include the actual combobox containing the components.

regards raidos
0
 
kretzschmarCommented:
a recursion call isn't needed raidos,
because normally all components
are owned by the form where they are dropped.

another thing is the control-list

meikl ;-)
0
 
PieterJAuthor Commented:
Thank you very much guys !!

Pieter
0
 
raidosCommented:
Kretschmar, as i understood it, recursion was needed since he had components on panels, but i might be wrong..

anyway, it doesn't matter..=))

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now