TSpeedButton(FindComponent('SpeedButton'+IntToStr(4))).Caption :='快速按钮(4)';

解决方案 »

  1.   

    TForm1 = class(TForm)
    private
      FSpeedButtons:Array[1..20] of TSpeedButtons;
    public
    end;TForm1.Form1Create(Sender:TObject);
    var
      iCount:Integer;
    begin
      for iCount :=1 to 20 do
      begin
        FSpeedButtons[iCount] := 
          TSpeedButton(FindComponent('SpeedButton'+IntToStr(iCount));
      end;
    end;//FSpeedButtons[iCount]就可以用了
      

  2.   

    Sorry! FSpeedButtons:Array[1..20] of TSpeedButton;没有s
      

  3.   

    TForm1.Form1Create(Sender:TObject);
    var
      i:Integer;
    begin
      for i :=1 to 20 do
      begin
        TSpeedButton(FindComponent('SpeedButton'+IntToStr(i))).Caption:= '快速按钮('+IntToStr(i)+')';
        TSpeedButton(FindComponent('SpeedButton'+IntToStr(i))).Tag:= i;
      end;
    end;