Solved

List of Component Names

Posted on 2001-07-16
5
187 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

21 Experts available now in Live!

Get 1:1 Help Now