Solved

List of Component Names

Posted on 2001-07-16
5
196 Views
Last Modified: 2010-04-06
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
Comment
Question by:PieterJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 25 total points
ID: 6285540
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
 
LVL 3

Expert Comment

by:raidos
ID: 6285556
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6285574
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
 

Author Comment

by:PieterJ
ID: 6285725
Thank you very much guys !!

Pieter
0
 
LVL 3

Expert Comment

by:raidos
ID: 6287462
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question