lucyyuan1 2016-12-10 14:24 采纳率: 50%
浏览 986
已采纳

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条回答 默认 最新

  • threenewbee 2016-12-10 15:55
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试