把窗体中所有的Button的Enabled置为False

把窗体中所有的Button的Enabled置为False

procedure TForm1.FormCreate(Sender: TObject);
var index:integer;
begin
For Index:=0 to ControlCount-1 do
 if Components[Index] is TButton then
  begin
   (Components[Index] As TButton).enabled:=False;
  end;
end;
end.
 
//设置窗体中所有Button的Enabled为False
procedure TForm2.Button3Click(Sender: TObject);
var 
i:integer;
begin
for i:=0 to self.ControlCount-1 do 
 if self.Controls[i] is TButton then 
   TButton(self.Controls[i]).Enabled:=False;
end;



你可能感兴趣的:(控件,类类型)