I want to know if it is possible in delphi to populate a combobox component from object Tcollection.
somme codes:
// My product list
procedure TfoMain.InitForm;
begin
FListProduct := TListeDispoProduit.Create(TProduct);
with (FListProduct ) do
begin
with TProduct(Add) do
begin
Name := 'Product 01';
CIP := 'A001';
StockQty := 3;
end;
with TProduct(Add) do
begin
Name := 'Product 02';
CIP := 'A002';
StockQty := 5;
end;
end;
// need to fill a combobox (name’s cbxListProduct)
procedure TfoMain.fFillCbxFromProductList(aProductList: FListProduct);
begin
// I don't know how to do this follow
foMain.cbxListProduct.Items.Add()
end;
thank you.
Something like this (change combobox and collection names to reflect your case):
And by the way, you don’t need that “foMain” in
It’s enough to write
When you’re inside of TfoMain’s procedure, TfoMain’s contents is accessible by default.