Richard2000
asked on
Array of components property
Hi,
I have 2 components that I am writing, let's call them TComponent1 and TComponent2.
Now TComponent1 needs to have an array of TComponent2's as a property that can be indexed. The closest thing that I can think of in Delphi's VCL to this is the TPopupMenu and TMenuItem, or TPageControl and TTabSheet.
There needs to be an easy way for the user of the components to...
* Interate through the array as a property in TComponent1 to access the TComponent2s.
* Allow instances of TComponent2 to be Added to the array property in TComponent1.
* Delete instances from the array property.
* Change the order of the items in the array property.
* Count the number of items in the array property.
I assume I would need a linked list somewhere (TList). Would anyone be able to give me any source code that would demonstrate the above?
Thanks in Advance,
Richard
I have 2 components that I am writing, let's call them TComponent1 and TComponent2.
Now TComponent1 needs to have an array of TComponent2's as a property that can be indexed. The closest thing that I can think of in Delphi's VCL to this is the TPopupMenu and TMenuItem, or TPageControl and TTabSheet.
There needs to be an easy way for the user of the components to...
* Interate through the array as a property in TComponent1 to access the TComponent2s.
* Allow instances of TComponent2 to be Added to the array property in TComponent1.
* Delete instances from the array property.
* Change the order of the items in the array property.
* Count the number of items in the array property.
I assume I would need a linked list somewhere (TList). Would anyone be able to give me any source code that would demonstrate the above?
Thanks in Advance,
Richard
Best to use TObjectList and set the OwnsObjects property to true.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.