Solved

List of Component Names

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Delphi component that can load a DLL in design time? 8 76
Delphi XE10, MySQL Query 4 167
Correct Component for Shopping Cart. 2 112
update joined tables 2 55
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

820 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