我有一个问题:
如果有Button1、Button2、Button3、Button4...Button10我想定义他的Enable为True,可不可以这样做?
For I:=1 to 10 do
ButtonI.Enable:=True;
就是说我想给动态控制控件!!

解决方案 »

  1.   

    不可以,你用这个代码for i:=1 to 10 do 
      if Assigned(Form1.FindComponent('Button'+IntToStr(i))) then
        (Form1.FindComponent('Button'+IntToStr(i)) as TButton).Enabled:=True;就是用FindComponent函数来遍历窗口上所有的Button(假设只有这11个Button),然后在找到的情况下设置属性!
      

  2.   

    for i:= 1 to 10 do
     if component[i] is tbutton then
       (component[i] as tbutton).enabled:=true;
      

  3.   

    实在不行的话,就用这个笨方法:
    Button1.Enable:=True;
    Button2.Enable:=True;
    ..........
    Button10.Enable:=True;