-1
我遇到问题。我有一组picturebox被拖入一个picturebox。如何在拖动后禁用特定的picturebox?所以,它不能再拖了。C#拖放图片框2
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
pictureBox1.DoDragDrop(pictureBox1.Image, DragDropEffects.All);
}
private void pictureBox2_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Bitmap))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private void pictureBox2_DragDrop(object sender, DragEventArgs e)
{
if ((e.Data.GetDataPresent(DataFormats.Bitmap)))
this.pictureBox2.Image = (Bitmap)(e.Data.GetData(DataFormats.Bitmap));
}
请添加代码 –
使用一个标志,可能在PB的标签中允许/禁止拖动!在'pictureBox1_MouseDown'测试它在每个'_DragDrop'事件中设置它! – TaW
@TaW我的想法确切:-) –