private void panel1_DragDrop(object sender, DragEventArgs e)
{
PictureBox pictureBox1 = (PictureBox)e.Data.GetData(typeof(PictureBox));
Panel panel1 = (Panel)sender;
panel1.Controls.Add(pictureBox1);
pictureBox1.Location = this.PointToClient(new Point(e.X - panel1.Left, e.Y - panel1.Top));
PictureBox pictureBox2 = (PictureBox)e.Data.GetData(typeof(PictureBox));
panel1.Controls.Add(pictureBox2);
pictureBox2.Location = this.PointToClient(new Point(e.X - panel1.Left, e.Y - panel1.Top));
}
private void panel2_DragDrop(object sender, DragEventArgs e)
{
PictureBox pictureBox1 = (PictureBox)e.Data.GetData(typeof(PictureBox));
Panel panel2 = (Panel)sender;
panel2.Controls.Add(pictureBox1);
pictureBox1.Location = this.PointToClient(new Point(e.X - panel2.Left, e.Y - panel2.Top));
PictureBox pictureBox2 = (PictureBox)e.Data.GetData(typeof(PictureBox));
panel1.Controls.Add(pictureBox2);
pictureBox2.Location = this.PointToClient(new Point(e.X - panel1.Left, e.Y - panel1.Top));
}
放兩個label調試輸出下當前的x y看看