大家好:
     小弟已经从.NET转到Delphi了,最近有一个问题,要把RadioButton1到RadioButton200设置成不可用。在想可不可以用一个循环语句来实现,而不是一条一条书写。欢迎大家指点,谢谢大家!!!

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      i: integer;
    begin
      for i:=1 to 200 do
        if FindComponent('RadioButton'+IntToStr(i)) <> nil then
          TRadioButton(FindComponent('RadioButton'+IntToStr(i))).Enabled := false;
    end;
      

  2.   

    var
      i: integer;
    begin
      for i:= 0 to Form1.ControlCount -1 do
      begin
        if Self.Controls[i].ClassName = 'TRadioButton' then
          TRadioButton(Form1.Controls[i]).Caption := 'Test';
      end;
    end;