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;
for i:= 0 to ComponentCount - 1 do begin if Components[i] is TButton then (Components[i] as TButton).Enabled:= not Odd(i); end;
begin
if odd(I) then
begin
Tbutton(findcomponent('A' +inttostr(I)) ).enable := false;
end;
end;
for t:=1 to 25 do
beginTbutton(findcomponent('A' +inttostr(I)) ).enable := false;
i:=2i-1;
end;
是把你想disable的按钮放在一个panel和其他的容器里,
然后panel.enabled:=false;哈哈,搞定.
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;
begin
if Components[i] is TButton then
(Components[i] as TButton).Enabled:= not Odd(i);
end;