小弟初学delphi,请问如何实现如下的语句:
var i:integer;
i:=1;      //或者其他的整数,2,3,...
edit[i].caption:='hello';  //也就是edit1.caption:='hello';i:=2,就是edit2.caption:='hello';请问这句该怎么写?

解决方案 »

  1.   

    就这样写啊
    edit[i].caption:='hello';
    你要一次性全改成这个。最多加个for循环~
      

  2.   

    goodloop(小志) 已搞定了,塞车来晚 ~@_@~
      

  3.   

    假设你的Form1中有Edit1...Edit100
    var
     i:integer;
    begin
     for i:=1 to 100 do
      TEdit(Form1.FindComponent('Edit'+IntToStr(i))).Text:='hello';
    end;Edit好象没有Caption,有Text
      

  4.   

    假设你的edit2是TLabel
    (FindComponent('edit2') as tlabel)='hello';
      

  5.   

    假设你的edit2是TLabel
    (FindComponent('edit2') as tlabel).caption='hello';
    //Tedit是没有caption属性的
      

  6.   

    procedure TForm1.Button1Click(Sender: TObject);
    var i:integer;
    begin
    i:=1;
    edit[i].caption:='hello';
    end;出错为:Undeclared identifier:'edit'.
      

  7.   

    那个edit.caption是我随便写的,本来是button
      

  8.   

    谢谢了,我用
    TEdit(Form1.FindComponent('Edit'+IntToStr(i))).Text:='hello';
    这个行了。顺便问一下,我要将button1的1取出再放到变量i中,该怎么做呢?
      

  9.   

    i:=StrToInt(Copy(Edit1.Name,5,Length(Edit1.Name)-4));//从Edit1.Name的左数第5位(前4位字符为Edit)开始取,共取Length(Edit1.Name)-4位,即它的序号;不同的控件因英文名字的不同而取的开始位置不同