thank you for the help on how to create the combo box.
what i wanted to do was this (but with combobox indead of button):
Eh, TList??
var
Form1: TForm1;
ButtonList: TList;
implementation
procedure TForm1.FormCreate(Sender: TObject);
var i: integer
btn: TButton;
begin
// List to store buttons
ButtonList := TList.Create;
for i := 0 to 9 do
begin
btn := TButton.Create(self);
btn.Parent := self;
btn.Top := (i * (btn.Height + 3));
// ....
// Store the button for later reference
ButtonList.Add(btn);
end;
// Demo: label all buttons
for i := 0 to ButtonList.Count-1 do
TButton(ButtonList[i]).Caption := format('Button %d', [i]);
end;
Note: put all variables related to the form in the form class type specification.
For example:
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ private declarations }
ButtonList: TList;
public
{ public declarations }
end;
the problem is, when i click on my Button btnAddComboBox the new combobox doesn't appear under the first one (maybe they are laying on top of each other or the second one is the same as the first one...this is what i don't understand)
to answer your question, i have some global var:
cbList: TList; //holds all added comboboxes
cbText: TComboBox; //template for comboboxes
slData: TStringList; //items inside combobox
slData has two string 'Hello' and 'World'
i want my program to start with one combox where i can select one of the two strings and a button which shoud create a copy of the first combobox under it!