为每个控件的TAG属性赋值,然后根据TAG的值来改变Enabled属性

解决方案 »

  1.   

    见楼上的方法Tbutton(sender).tag
      

  2.   

    若是按扭变为菜单呢?就是说可以同样用这样方法来操作菜单的Enabled吗?
      

  3.   

    for I := 1 to 50 do 
    begin
      if odd(I) then
      begin
        Tbutton(findcomponent('A' +inttostr(I)) ).enable := false;
      end;
    end;
      

  4.   

    i:=1
    for t:=1 to 25 do 
    beginTbutton(findcomponent('A' +inttostr(I)) ).enable := false;
    i:=2i-1;
    end;  
      

  5.   

    简单的方法是....
    是把你想disable的按钮放在一个panel和其他的容器里,
    然后panel.enabled:=false;哈哈,搞定.
      

  6.   

    procedure TForm1.BitBtn1Click(Sender: TObject);
    var s:string;
    i:integer;
    begin
       FOR  i:=0 to  form1.Controlcount-1 do
       begin
            if controls[i].classname='TButton' then
            begin
                 s:=(controls[I] as TButton).Name;
                 s:=copy(s,2,(length(s)-1));
                 if odd(strtoint(s)) then
                 (controls[I] as TButton).Enabled:=false;
            end;
       end;
    end;
      

  7.   

      for i:= 0 to ComponentCount - 1 do
      begin
        if Components[i] is TButton then
          (Components[i] as TButton).Enabled:= not Odd(i);
      end;