我大体知道是这样
for i := 0 to panel1.ComponentCount - 1 do
begin
   //里面怎么写啊?
end;

解决方案 »

  1.   

    先uses个TypInfoprocedure TMainForm.Button1Click(Sender: TObject);
    var
      i: Integer;
      PropInfo: PPropInfo;
    begin
      with Panel1 do 
        for i := 0 to ControlCount - 1 do
        begin
          PropInfo := GetPropInfo(Controls[i], 'Color');
          if (PropInfo <> nil) and
          (PropInfo.PropType^.Kind = tkInteger) then
            SetOrdProp(Controls[i], 'Color', clRed);
        end;
    end;
      

  2.   

    我所知道的就是你所大体知道的是错的~~
    ComponentCount是访问子元件,不是子控件~~
    窗体设计期放的控件都是Form的子元件~~元件(TComponent)就是可放在元件板上的东东~~
    最主要的特性就是有Name、Owner、ComponentCount、Tag等属性~~
    这里的Owner属性就是父元件~~
    通过ComponentCount、Components可以遍历其子元件~~控件(TControl)就是可以显示出来的元件~~
    最主要的特性就是有Parent、Left、Top、Color等属性~~
    Parent就是其容器,它的类型是TWinControl~~窗体控件(TWinControl)就是可以当容器的控件~~
    最主要的特性就是有ControlCount、Handle、ImeMode、ImeName等属性~~
    通过ContorlCount、Controls可以遍历其子控件~~Panel是就从TWinControl继承来的窗体控件~~
    放在Panel上的控件就是Panel的子控件~~
    Panel就它们的容器(Parent)~~所有用TPanel.ComponentCount来遍历其子控件就是做梦~~
    需要用TPanel.ControlCount、PanelControls属性~~uses TypInfo;procedure TForm1.FormCreate(Sender: TObject);
    var
      I: Integer;
    begin
      //这里要注意的是我大体知道在Published中的属性才有RTTI(运行期类型信息)
      for I := 0 to Panel1.ControlCount - 1 do begin
        if IsPublishedProp(Panel1.Controls[I], 'Color') then //安全第一~~
          SetOrdProp(Panel1.Controls[I], 'Color', clRed);
        if IsPublishedProp(Panel1.Controls[I], 'Text') then //安全第一~~
          SetStrProp(Panel1.Controls[I], 'Text', 'Red');
        if IsPublishedProp(Panel1.Controls[I], 'Caption') then //安全第一~~
          SetStrProp(Panel1.Controls[I], 'Caption', 'Red');
      end;
    end;
      

  3.   

    zswang(伴水):
    大侠手笔,佩服!!
      

  4.   

    佩服 zswang(伴水)(现在是专家门诊清洁工) ,不愧为 4 星。
      

  5.   

    zswang(伴水)(现在是专家门诊清洁工) 兄果然高明,一席话让在下毛塞顿开,高明高明。