TLabel(FindComponent('Label45')).caption:='123';
//怎么不行??直接
Label45.caption:='123';//都可以

解决方案 »

  1.   

    没问题呀
     TLabel(FindComponent('Label1')).caption:='123'
      

  2.   

    应该可以啊,是不是你的Label45是动态创建的,创建时没有指定Owner?
      

  3.   

    TLabel(FindComponent('Label45')).caption:='123';我帮你试了,可以的,不知道你为什么不行,有什么提示吗
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    var lbl: TLabel;
    begin
      lbl := TLabel.Create(Form1);  // 这里要指定Owner
      lbl.Name := 'Label45';
      lbl.Parent := Form1;
      lbl.Visible := True;
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      TLabel(FindComponent('Label45')).Caption := '123';  // 这边才能找到
    end;
      

  5.   

    Owner不同导致的问题
    要是你的Lable在Panel里就必须使用TPanel的FindComponent
    默认的FindComponent是当前的Form!/ by LY http://lysoft.7u7.net http://liuyang.7i24.com
      

  6.   

    Label不是动态创建的,但Form2是动态创建的,真的不行的
      

  7.   

    Label45的caption显示还是空白;直接就没问题
      

  8.   

    那么你那句话写在form2单元中了吗?
    如果没有就应该这样写:TLabel(Form2.FindComponent('Label1')).caption:='123'
      

  9.   

    ok,问题解决,实在多谢各位.尤其是zwjchina朋友,给分了。分数不多,请笑纳了,不用客气