C#.NET 中 我先是启动了一个Form1,然后在Form1里面有个Button, 点击一下。又启动了Form2(我是让Form2和Form1对齐的,紧挨着Form1 this.Left =f1.Left+f1.Width;
this.Top=f1.Top;)。现在我想让Form1永远成为焦点,而且在拖动或是最小化或是关闭Form1时,Form2也随之变化,Form2永远跟着Form1 ,永远紧挨着他,在没关掉Form1之前事关不掉Form2的,我应该如何做呢,请大侠帮忙

解决方案 »

  1.   

    各位大侠,能给点代码吗,具体的方法,我是刚学的,QQQ
      

  2.   


     private void Form1_LocationChanged(object sender, EventArgs e)
            {        }
    然后把FORM2的动作写到里面
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;using System.Text;
    using System.Windows.Forms;namespace WindowsApplication2
    {
        public partial class Form1 : Form
        {
            Form2 f2 = new Form2();
            int y;
            Rectangle rect;
           
           
        
            public Form1()
            {
               
                
                InitializeComponent();
               
               
            }
              
            private void button1_Click(object sender, EventArgs e)
            {
               
                y = this.Location.X + this.Width;
                rect = new Rectangle(y, this.Location.Y,300, 300);
                          f2.StartPosition = FormStartPosition.Manual;
                
                f2.Bounds = rect;
                f2.Show();
      
               
            }               private void Form1_Move(object sender, EventArgs e)
            { Rectangle  R2=new Rectangle (this.Location.X +this .Width ,this .Location.Y,300,300);
            f2.Bounds = R2;
            this.Focus();        }      
        }
    }
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication2
    {
        public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }        private void Form2_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (e.CloseReason == CloseReason.UserClosing)
                {
              
                    e.Cancel = true;
                 this.Hide ();
                }
                else
                {
                  
                }         
            }
        }
    }
    保你行,积分全给我吧,不行找我,给你大包发送。
      

  4.   

    “partial” 怎么老报错啊?
      

  5.   

    呵,实现不了的话,那就去找他吧
    欢迎大家来的我博客
    http://blog.csdn.com/csdbfans
      

  6.   

    partial shi VS.net 2005中带的部分类的标识符.
    楼主的要求估计得需要在form1中鼠标拖动和windows消息里进行处理吧.
      

  7.   

    你真的是个小白,什么也不知道,把你邮箱告诉我,我打包发给你。我运行一点问题也没有,你只是没有弄好,邮箱,tell me!
      

  8.   

    完了,huoyingyangjie 发给我的东西,我打不开,我是2003版本的
      

  9.   

    你奶奶的,我受不了,我无语,就算,直接打不开,你不会看form1.cs和form2.cs啊,打开方式记事本,真是的!算了。就当我什么也没说!