Delphi/CB
•  Greatis •  Security •  AppDatabase •  Utilities •  Visual Basic • .NET •  just4fun
Delphi / C++ Builder
Components, utilities and tips for Delphi and C++ Builder developers
Hot Offer
Save your money!
Featured
Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

News Tips .NET Software VCL Software Partners  

Create an array of components
First of all, you need to declare the array.
Then, if you will create the Button components dynamically, you may execute procedure BitBtn1Click.
Then, if you will create the Button components static, you may execute procedure BitBtn2Click.

var
  Edits : array[1..5] of TEdit;
  SPButtons: array[1..5] of TSpeedButton;

implementations

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  i: Integer;
begin
  for i:=1 to 5 do
  begin
    Edits[i]:=TEdit.Create(Form1);
    Edits[i].Parent:= Form1;
    Edits[i].Left:=40;
    Edits[i].Top:=Form1.Height-(5-i)*40-100;
    Edits[i].Text:='Edit '+IntToStr(i);
  end;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
var
  Btns, Counter: Integer;
begin
  Btns:=0;
  for Counter:=0 to Form1.ComponentCount-1 do
  begin
    if (Components[Counter] is TSpeedButton) and (Btns<5) then
    begin
      Inc(Btns);
      SPButtons[Btns]:=TSpeedButton(Components[Counter]);
      SPButtons[Btns].Caption:='SP'+IntToStr(Btns);
    end
  end;
end;

Related chapters
Databases

Related topics
Create component at runtime
Add controls to TabbedNotebook
Create TTable without a form
Duplicate component

For more
Delphi Help

Download source


Our Partner
DevArchive.com
Recommended
just4fun
Useful Resources
Win32.hlp Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
Newsletters
Subscribe to our news!    Subscribe to our news!


Greatis Software Greatis | Security | AppDatabase | Utilities | Delphi/CB | Visual Basic | .NET | just4fun

Contacts | Add to Favorites | Recommend to a Friend | Privacy Policy | Copyright © 1998-2008 Greatis Software