您缺少TCategoryPanel创建TCategoryPanelSurface对象作为其构造函数中的子对象,因此所有控件都进入TCategoryPanelSurface对象,而不是进入TCategoryPanel。
ShowMessage(ListBox1->Parent->ClassName()); //you can see actual parent class here
TCategoryPanelSurface * Surface;
Surface = dynamic_cast <TCategoryPanelSurface *> (CatPan->Controls[0]);
ShowMessage(Surface->ControlCount);
ShowMessage(Surface->Controls[0]->Name); //you should use loop here to iterate through controls
var
Surface: TCategoryPanelSurface;
I: Integer;
begin
Surface := CatPan.Controls[0] as TCategoryPanelSurface;
for I := 0 to Surface.ControlCount - 1 do
begin
ShowMessage(Surface.Controls[I].Name);
end;
end;