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?
The value returned by mCommands[index] is of type TComponent. You can access any values exposed by TComponent, TPersistent, or TObject. If you want to access other members, then you need to tell the compiler what type it is. The compiler doesn't know anything about types except what it sees in declarations. var macro: TMacroCombo; macro := TMacroCombo.Create(Self, cCommand); macro.Align := alLeft; macro.ItemIndex := 0; mCommands.Add(macro); -- Rob _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

