试一试:ComboBox1.Parent:=Panel1;

解决方案 »

  1.   

    同意CsdnKey﹐本來就是這樣做的!
      

  2.   

    var
      i:integer;
    begin
      for i:=form1.ComponentCount-1 downto 0 do
        begin
          if form1.Components[i] is Tcombobox then
              form1.Components[i].parent:=panel1;
        end;
    end;  
      

  3.   

    var
      i:integer;
    begin
      for i:=form1.ComponentCount-1 downto 0 do
        begin
          if form1.Components[i] is Tcombobox then
              Tcombobox(form1.Components[i]).parent:=panel1;
        end;
    end;
      

  4.   

    当从FORM上移去一个组件时,就相当于隔离了这个组件和FORM的联系,好像会设置组件=nil;
      

  5.   

    to liang_z:按你的试了,不过在panel1中并不显示combobox1.
      

  6.   

    var
      i:integer;
    begin
      for i:=form1.ComponentCount-1 downto 0 do
        begin
          if form1.Components[i] is Tcombobox then
          begin
              Tcombobox(form1.Components[i]).parent:=panel1;
              Tcombobox(form1.Components[i]).Left := 0;
              Tcombobox(form1.Components[i]).Top :=0;
          end;
        end;
    end
      

  7.   

    Left和Top是相对于Parent左上角的位置!
    你的combobox1原来的位置相对于Form左上角的位置一定比较大
    以致于以这个相对位置放到panel1上后超出了panel1的显示范围!
    如原来combobox1的Left := 200;而panel1的Width := 100;
      

  8.   

    Left和Top是相对于Parent左上角的位置!
    你的combobox1原来的位置相对于Form左上角的位置一定比较大
    以致于以这个相对位置放到panel1上后超出了panel1的显示范围!
    如原来combobox1的Left := 200;而panel1的Width := 100;
      

  9.   

    不可能﹐你設置了坐標之類的﹐賦于parent屬性一定會顯示
      

  10.   

    用Tcombobox(form1.Components[i]).parent:=panel1;实现了combobox的移动之后,还必须对它的位置重新设定,否则它可能被放置在panel的不可视区域中,你就没有办法看到它了。如果要试一下这个效果,试把一个控件从form上cut之后再paste到一个panel里,你会发现控件的位置(top,left)还是会保持在form时的值