窗体有EDIT1、EDIT2到EDIT9个控件我想一次过改变其Enable属性为False,于是写下代码:procedure TForm3.BitBtn1Click(Sender: TObject);
var
  I:Integer;
  Y:String;
begin
   For I:= 1 To 9 Do
   Y:=IntToStr(I);
   'Edit'+Y+'.Enable:=True';
end;但出错,捍示:[Error] MainAdd.pas(69): Statement expected, but expression of type 'String' found应该怎么写才正确呢?最后谢谢阅读!

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      iCount:Integer;
    begin
      for iCount:=0 to ControlCount-1 do
      begin
        if not (Controls[iCount] is TEdit) then Continue;
        (Controls[iCount] as TEDit).Enabled:=true;
      end;
    end;
      

  2.   

    for i := 1 to Form3.ControlCounts - 1 do
      if Form3.Controls[i] is TEdit then TEdit(Form3.Controls[i]).Enabled := true;
      

  3.   

    谢谢以上两位,但不行呢?会不会是因为我把EDIT放在GroupBox里面的原因呢?
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      iCount:Integer;
    begin
      for iCount:=0 to GroupBox1.ControlCount-1 do
      begin
        if not (GroupBox1.Controls[iCount] is TEdit) then Continue;
        (GroupBox1.Controls[iCount] as TEDit).Enabled:=true;
      end;
    end;
      

  5.   

    procedure TForm1.Button2Click(Sender: TObject);
    var
      i:Integer;
    begin
         for i:=0 to Self.ComponentCount-1 do
           if self.Components[i] is TEdit then
              (Self.Components[i] as TEdit).enabled:=False;
    end;
      

  6.   

    谢谢了!原来要加GroupBox1,我是这样写的,也通过。   for i := 1 to Form3.GroupBox1.ControlCount - 1 do
         if Form3.GroupBox1.Controls[i] is TEdit then TEdit(Form3.GroupBox1.Controls[i]).Enabled := true;
       begin结贴!
      

  7.   

    框当
    楼主,不要以为给一个字符串赋值为'edit1'它就有了enable属性……
      

  8.   

    刚在这个贴子里说了这个问题
    http://community.csdn.net/Expert/topic/4031/4031714.xml?temp=.2027399