"a component named button1 already exist"
你的控件名字重复了吧?

解决方案 »

  1.   

    我的form上就只放一个button,其他什么都没有放,怎么可能重复呢,而且我如果改变button的name属性,它还是会说这句话,只是变成了"a component named 新的名字 already exist"
    (我又不是看不懂英文)
    不信自己去试。
      

  2.   

    好像是这样,你自己再调一下吧!!
    procedure TForm1.Button1Click(Sender:Tobject);
    var
      MyObj:TButton;
      MyName:String;
    begin
      MyObj:=TButton.Create(Self);
      MyObj.parent:=Self;
      MyObj.Left:=xxxx;(*数字随你便,下同*)
      MyObj.Top:=xxxx;
      inc(Counter)(*作为计数用,全局量,自己声明去吧*)
      Myname:=Tbutton.Classname+inttostr(Counter);(*这里错了,就会出现你好种错*)
    (*只是定义名字,即name属性,也可以是别的,但注意,不要重名*)
      Delete(myname,1,1);(*支掉T*)
      MyObj.Name=MyName;
      MyObj.Visible:=true;
    end;initialization
      registerclasses([Tbutton]);(*好像可以不要*)
    end.
    大概就这样,如果还有其它的错误,我回去仔细看一下再告诉你如果行得通的话,别忘了给我加分,因为我没分了:-),
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      with TLabel.Create(Self) do
      begin
        Parent:=Self;
        Caption:=动态标签';
      end;
    end;
    可为什么这样就可以,我那样就不可以呢
      

  4.   

    终于知道错在哪儿了dyLbl := dyLbl.Create(Self) => dyLbl := TLabel.Create(Self) 就对啦