我正在尝试将一个图片框拖放到另一个图片框中。 请帮我! 谢谢 最诚挚的问候
答案 0 :(得分:2)
请参阅此http://www.codeguru.com/Csharp/Csharp/cs_syntax/controls/article.php/c5865
<强> Upadated:强> 做一个技巧
bool holdsImage = false;
Control currentControl = null;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
holdsImage = true;
}
private void pictureBox2_MouseEnter(object sender, EventArgs e)
{
currentControl = pictureBox2;
}
private void pictureBox2_MouseLeave(object sender, EventArgs e)
{
currentControl = null;
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
if (holdsImage && currentControl==pictureBox2)
{
pictureBox2.Image = pictureBox1.Image;
pictureBox1.Image = null;
}
holdsImage = false;
currentControl = null;
}
问题是我无法在PictureBox中找到AllowDrop属性,否则DoDragDrop()