John Barrat wrote:
> I am writing an application which needs to create a number of components
> (all of the same type - a custom ComboBox).  To manage these I have been
> tryig to use TComponentList but having added these to a TComponentList I
> cannot see how I access there components.
>  
> e.g.
> mCommands := TComponentList.Create;  // create the component list
> // create a new component and add it to the ComponentList.
> mComIdx := mCommands.Add(TMacroCombo.Create(Self, cCommand));
>  
> Now how do I access the properties of the component I have just added? 
>  
> I had assumed I could do something like this....
>  
> With mCommands[index] do begin
>     align := alLeft;
>     ItemIndex := 0;
>     etc...
> end
>  
> Have I misunderstood completely on how this class is used?

Probably not, the trick is that ComponentList exposes a 
collection of TComponent references.

So, in order to use them as whatever you actually stored in the 
list instead of just TComponents you have to do some typecasting:

with (mCommands[index] as TMacroCombo) do begin
   align := alLeft;
   ItemIndex := 0;
   etc...
end;

Make sense?

Stephen Posey
[EMAIL PROTECTED]

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to