picture2在panel1或2的位置总是不对,但是picture1确实正确的

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));

    }

1个回答

放两个label调试输出下当前的x y看看

lucyyuan1
lucyyuan1 已解决
大约 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问