component与control的不同

相同:这两个属性都表示该容器类控件中的子控件

不同:当容器类控件中的子控件也存在容器类控件时

   可用component.component....,control则不能这样书写

   即control中不包含子控件中的容器类控件

举例:如何循环控制控件中的子控件

 1   myopensql(ibqry1,'select distinct laneno from smp');
2 //在找出的不同泳道名称表中做循环
3 with ibqry1 do
4 begin
5 First;
6 while not eof do
7 begin
8 //2.对k进行赋值即当前泳道号
9 k := ibqry1.fields[0].asinteger;
10 //3.对窗体中所有控件做循环
11 for m := 0 to self.ComponentCount - 1 do
12 begin
13 //4.找出泳道panel
14 if (Self.Components[m].Tag = k) and (Self.Components[m] is TbsSkinPanel) then
15 begin
16 //5.对泳道panel上的子控件做循环,子控件可见
17 for n := 0 to TbsSkinPanel(self.Components[m]).ControlCount - 1 do
18 begin
19 TbsSkinPanel(self.Components[m]).Controls[n].Visible := True;
20 end;
21 end;
22 end;
23 //6.查找下一K,即下一泳道编号重复以上操作
24 Next;
25 end;
26 end;

   

posted @ 2011-08-12 18:17  宋扬  阅读(565)  评论(0编辑  收藏  举报