例:str1 :string;
    str1 := 'Button1';
如何实现: str1.Caption := 'Hello';  
我想了很久没能实现,请教大家。

解决方案 »

  1.   

    你写的不可能实现!
    不过我好象明白你的意思,下面的代码也许能够完成你的功能:
    procedure TForm1.Button2Click(Sender: TObject);
    var
      i:integer;
    begin
      for i:=0 to self.ComponentCount-1 do
      begin
        if (self.Components[i] is TButton) then
          if TButton(self.Components[i]).name='Button1' then
             TButton(self.Components[i]).caption:='Hello';
      end;
    end;