日期:2014-05-17 浏览次数:21102 次
public partial class Form1 : Form
{
Form2 f = null;
int initx = 0;//初始left距离
int inity = 0;//初始top距离
int initx1 = 0;//初始left距离
int inity1 = 0;//初始top距离
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
f = new Form2();
f.Show();
initx = this.Left;
inity = this.Top;
initx1 = f.Left;
inity1 = f.Top;
}
private void Form1_Move(object sender, EventArgs e)
{
if (f != null)
{
f.Top = initx1 + (this.Top - inity);
f.Left = inity1 + (this.Left - initx);