就是我已经在Form1中有一个 比如 Tedit的控件 Edit1现在 我有个字符串 Str:='edit1=hello';要做的是 将Str串中 = 右边的值"hello" 赋给以 = 左边字符串为名称的控件怎么做? 我试了下不能直接这样 str1:='edit1' ; Tedit(str1).text:=hello  --这样会出错又试了下 str1:Tcomponent; str1=Tcomponent.create(self); Tedit(str1).name:=edit1
还是错,因为重名了不知道咋办了??谢谢

解决方案 »

  1.   

    Form1.FindComponent('edit1').Text := 'hello';
      

  2.   

    谢谢不过得加个 Tedit(FindComponent('edit1')).Text这样才没错
      

  3.   

    又有问题了:Form1.FindComponent('edit1').Text := 'hello';==这样不能加text ,会报错可是 如果 加了  Tedit(FindComponent('edit1')).Text= 那就不能在TEdit前加Frm了
    比如 Frm1.Tedit(FindComponent('edit1')).text=...  这样就会报错,说text未定义??
      

  4.   

    (Form1.FindComponent('edit1') as TEdit).text := 'hello';