我在ScrollBox上放了一些控件,现在想得到控件的个数

ScrollBOX1.ComponentCount为什么返回的总是 0?

解决方案 »

  1.   

    showmessage(inttostr(scrollbox1.ControlCount ))
      

  2.   

    ComponentCount是它拥有的控件,你放在窗体上的控件的拥有者是窗体.
      

  3.   

    我也有同样的问题;
    按照delphi帮助中的解释;
    The ComponentCount of a component contains the same number of items as in the Components list for that component,说componentcount属性是在某个控件的控件列表下的控件的条数;
    我甚至先在另外一个事件中将一些控件的parent用代码设置了;但是还不行;
    在显示的时候仍然是零;
      

  4.   

    用顶楼的controlcount属性倒是可以;
    注释中说:Read ControlCount when iterating over all the children of this control. The children of the control are listed in the Controls property array.
    这个跟component有什么区别;?