C# C-拖放并保持控制

C# C-拖放并保持控制,c#,drag-and-drop,C#,Drag And Drop,因此,我试图制作一个拖放应用程序,在面板上拖动一些东西。我以前做过,但我忘记了我使用的代码。我也希望它也有一个活动。以下是一个失败的示例: private void pictureBox1_Click(object sender, EventArgs e) { PictureBox flower1 = new PictureBox(); flower1.Image = pictureBox1.Image; flower1.Locat

因此,我试图制作一个拖放应用程序,在面板上拖动一些东西。我以前做过,但我忘记了我使用的代码。我也希望它也有一个活动。以下是一个失败的示例:

    private void pictureBox1_Click(object sender, EventArgs e)
    {
        PictureBox flower1 = new PictureBox();
        flower1.Image = pictureBox1.Image;
        flower1.Location = new Point(panel1.Location.X, panel1.Location.Y);
        flower1.Width = 100;
        this.Controls.Add(flower1);
        flower1.MouseDown += new MouseEventHandler(flower1_MouseDown);
    }

    void flower1_MouseDown(object sender, MouseEventArgs e)
    {
        //flower1.Location = new Point(MousePosition.X, MousePosition.Y);
    }
我想让我点击一朵花,然后它会被放在面板上,如果鼠标被点击在复制到面板上的控件上,那么将该位置作为鼠标光标的位置。我该怎么做呢?它甚至看起来都不重复

编辑:刚意识到图像位于面板下方,无法看到。这是一个问题,现在我如何让它拖放

private void pictureBox1_Click(object sender, EventArgs e)
{
    PictureBox flower1 = new PictureBox();
    flower1.Image = pictureBox1.Image;
    flower1.Location = Point.Empty;
    flower1.Width = 100;
    flower1.Parent = panel1;
    flower1.MouseDown += new MouseEventHandler(flower1_MouseDown);
}