-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我的想法確切:-) –