Solved

List of Component Names

Posted on 2001-07-16
5
184 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
  • 2
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 25 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you very much guys !!

Pieter
0
 
LVL 3

Expert Comment

by:raidos
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now