在form1中有一个label和一个命令按钮,我想用命令按钮来控制label在form1和form2中变来变去如何实现?请指教。

解决方案 »

  1.   

    label在form1和form2中变来变去?
    說清楚一點....
      

  2.   

    var
      AComp: TComponent;
    begin
      if Assigned (Label1) then
      begin
          Label1.Parent := Form2;
          AComp := Label1;
          RemoveComponent (AComp);
          Form2.InsertComponent (AComp);
      end
    end;
      

  3.   

    use two labels and set the propertis visible and caption
      

  4.   

    如果可以用两个Label的话,楼上的就可以了啊如果只要一个的话,2楼的就是……
      

  5.   

    2楼的方法我用过、它只能把label从form1移到form2,不能把label从form2移到form1。
    我只能用一个label.
      

  6.   

    你设一个标志判断一下,在把二楼的代码改一下就成了。var
      BForm1:boolean;//判断LABEL在那个窗口上 TRUE FORM1上var
      AComp: TComponent;
    begin
     if BForm1 then
      if Assigned (Label1) then
      begin
          Label1.Parent := Form2;
          AComp := Label1;
          RemoveComponent (AComp);
          Form2.InsertComponent (AComp);
      end
      else
    if Assigned (Label1) then
      begin
          Label1.Parent := Form1;
          AComp := Label1;
          RemoveComponent (AComp);
          Form1.InsertComponent (AComp);
      end;
      
      
    end;
      

  7.   

    你设一个标志判断一下,在把二楼的代码改一下就成了。var
      BForm1:boolean;//判断LABEL在那个窗口上 TRUE FORM1上var
      AComp: TComponent;
    begin
     if BForm1 then
      if Assigned (Label1) then
      begin
          Label1.Parent := Form2;
          AComp := Label1;
          RemoveComponent (AComp);
          Form2.InsertComponent (AComp);
          BForm1:=False;
      end
      else
    if Assigned (Label1) then
      begin
          Label1.Parent := Form1;
          AComp := Label1;
          RemoveComponent (AComp);
          Form1.InsertComponent (AComp);
          BForm1:=True;
      end;
      
      
    end;
      

  8.   

    为什么楼主一定只用一个Label?