What's wrong is that you are looping over the Components
property. That lists the components that are owned by the tab sheet. For components created in the form designer, the form is the owner. So it is expected that pagUsers.Properties.ActivePage.ComponentCount
is zero since the only thing on your form that owns anything is the form itself.
What you need to to is use ControlCount
and Controls[]
to iterate over the children of the tab sheet. Simply replace all use of ComponentCount
with ControlCount
, and likewise replace Components[]
with Controls[]
.
Note that the ControlCount
and Controls[]
properties only give the immediate children. Since you have panels you most likely have the panels as children of the tab sheet, and the check boxes as children of the panels. So you need to iterate over the children of the panels.
My answer here shows one way to do that. If you use the code I presented there then your iteration over checkboxes can be written very simply indeed:
TabSheet := pagUsers.Properties.ActivePage;
for CheckBox in TControls.Enumerator<TcxDbCheckBox>(TabSheet) do
....