> Date: Thu, 15 Feb 2007 18:30:26 -0000 > From: "John Barrat" <[EMAIL PROTECTED]> > Subject: Help needed Using TComponentList > To: "'Borland's Delphi Discussion List'" > > 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? > > JohnB
John, You are adding controls not components. Components do not have left, top ... properties. Everytime you create a control and add it to another (MyControl.Parent := MyPanel) that control is added to its parents controllist. You can get to this controllist with MyPanel.Controls an indexed list I destroy in my code every control that I add but it shouldn't be necessary - normal control clean up is to free all controls that it owns. hth Mick _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

