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]就可以用了
Sorry! FSpeedButtons:Array[1..20] of TSpeedButton;没有s
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;
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]就可以用了
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;