Ddo1.com WebMaster & Kodlama Forumu

Tam Versiyon: C# PictureBox Drag and Drop (Sürükle Bırak)
Şu anda arşiv modunu görüntülemektesiniz. Tam versiyonu görüntülemek için buraya tıklayınız.
Öncelikle pictureboxun AllowDrop özelliğini True yapın.

Kod:
this.pictureBox2.AllowDrop = true;


PictureBox MouseMove eventine alttaki kodları ekleyin

Kod:
private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
pictureBox1.DoDragDrop( pictureBox1.Image, DragDropEffects.All );
}

PictureBox Drag Enter kısmına alttaki kodları ekleyin

Kod:
private void pictureBox2_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{

if ( e.Data.GetDataPresent( DataFormats.Bitmap ) )
  {
   e.Effect = DragDropEffects.Copy;
  }
else
  e.Effect = DragDropEffects.None;
}

PictureBox Drag Drop kısmına alttaki kodları ekleyin.

Kod:
private void pictureBox2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
if ( (e.Data.GetDataPresent(DataFormats.Bitmap)))

this.pictureBox1.Image = (Bitmap)(e.Data.GetData(DataFormats.Bitmap)); 
}
}