Jud 1 Posted Sunday at 08:00 PM I'm trying to space a bunch of radio groups on a tab sheet. I have this in the form activate: var i, TheTop : integer; begin TheTop := 14; for i := 0 to TabSheet6.ComponentCount - 1 do if TabSheet6.controls[ i] is TRadioGroup then begin TabSheet6.controls[ i].top := TheTop; inc( TheTop, 32); end; // for i end; but the CompontentCount is 0 (here and the other TabSheets). What am I doing wrong? Share this post Link to post
Uwe Raabe 2157 Posted Sunday at 08:47 PM As you are already accessing TabSheet6.Controls, you better use ControlCount instead of ComponentCount. Share this post Link to post
Jud 1 Posted Sunday at 08:54 PM That was the problem - thanks! (I haven't done one of these in quite a few years.) Share this post Link to post
Remy Lebeau 1604 Posted Monday at 04:00 AM The TComponent.Components list contains the TComponent objects that are owned by the containing TComponent for memory management purposes. All components created at design-time are owned by the parent TForm/TFrame/TDataModule that they were dropped onto. This is why your TTabSheet's ComponentCount is 0 at runtime as it doesn't own anything. The TWinControl.Controls list contains the child TControl objects that are nested inside of the containing TWinControl for UI purposes. This is why your code works when you use the TTabSheet's ControlCount as its child controls list is not empty. Share this post Link to post