就在 private void button1_Click(object sender, EventArgs e)
        {
            Form f = new Form2();
            f.Show();//弹出form2
            f.StartPosition = FormStartPosition.Manual;
            f.Left = this.Left + this.Width;
            f.Top = this.Top;//设置form2位置
          
        }        private void Form1_Move(object sender, EventArgs e)
        {
            Form f = new Form2();
            f.Location = new Point(this.Location.X + this.Width, this.Location.Y);//form2随着form1移动
            
        }
不知道为什么不正确,只能实现form2挨着form1 不能随其form1移动而移动
请哪位大神帮忙改下,让我能实现这个功能!!!

解决方案 »

  1.   


    Form f = new Form2();private void button1_Click(object sender, EventArgs e)
      {
      f.Show();//弹出form2
      f.StartPosition = FormStartPosition.Manual;
      f.Left = this.Left + this.Width;
      f.Top = this.Top;//设置form2位置
        
      }  private void Form1_Move(object sender, EventArgs e)
      {
      f.Location = new Point(this.Location.X + this.Width, this.Location.Y);//form2随着form1移动
        
      }
    可以试试这样
      

  2.   

    Form f = new Form2();
    你又new了一个form2,这个form2已经不是你刚才的form2了,你大爷仍然是你大爷