有一panel,其中有数个控件,但panel.componentcount却是0,不知因何如此,请高人指点

解决方案 »

  1.   

    控件数是粘贴在panel上的吗?不能直接拖到panel上,用粘贴
      

  2.   

    ShowMessage(IntToStr(Panel1.ControlCount));
      

  3.   

    var I: integer;
    begin
     for I:=0 to Panel1.ControlCount-1 do
     begin
       Memo2.Lines.Add(Panel1.Controls[i].Name);
     end;
      

  4.   

    他上的compent不一定都是他的子窗口,只是位置的包含
      

  5.   

    你移动Panel,其中的控件会跟着动么?是,则那些控件的Parent是Panel,否则,parent就不是Panel,
    可在运行时刻类似 Control_x.parent:=Panel 的语句来进行设置
      

  6.   

    controlcount是可以的,我只想知道为什么componentcount不行
    另controlcount与componentcount有何区别
      

  7.   

    是呀,有些虽然显示在panel上,但其paraent不一定就是panel呀,去object treeview看一下关系吧
      

  8.   

    你的其它控件的父窗口不见得是你说的那个PANEL
      

  9.   

    推荐《Delphi6从入门到精通》里面有详解
      

  10.   

    在Panel内不一定是属于Panel的,看一下里组件的Parent是不是Panel如果是一定可以!
      

  11.   

    不会在运行时改变了parent吧?
      

  12.   

    我也觉得要看看TreeView才能确定,他们的关系
      

  13.   

    件数是粘贴在panel上的吗?不能直接拖到panel上,用粘贴???奇怪?不粘贴怎么会显示。
      

  14.   

    property ComponentCount: Integer;DescriptionUse ComponentCount to find or verify the number of components owned by a component, or when iterating through the Components list to perform some action on all owned components. ComponentCount is used internally for such iterative procedures.Note: The ComponentCount of a component contains the same number of items as in the Components list for that component, and is always 1 more than the highest Components index, because the first Components index is always 0. 
    =========================================================================================
    property ControlCount: Integer;DescriptionRead ControlCount when iterating over all the children of this control. The children of the control are listed in the Controls property array.ControlCount is a read-only property.Note: The value of ControlCount is always 1 greater than the highest Controls index, because the first Controls index is 0.
    这是D6的HELP,不知楼主看过没?先看一下帮助能解决很多问题。
      

  15.   

    ShowMessage(IntToStr(Panel1.ControlCount));
      

  16.   

    Panel上的控件Owner应该是form,所以componentcount为0
      

  17.   

    如果楼住用的不是panel而是frame,那么可能componentcount就行了。
      

  18.   

    呵呵,这么多人说。应该用粘贴的,先点PANEL,再按