You need to enable JavaScript to run this app.

Skip to main content

C# PictureBox Drag and Drop (Sürükle Bırak)

C# PictureBox Drag and Drop (Sürükle Bırak)

Gezgin
C# PictureBox Drag and Drop (Sürükle Bırak)
Ö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)); 
}
}

İçerik sağlayıcı paylaşım sitesi olarak hizmet veren Ddo1.com WebMaster & Kodlama Forumu sitemizde 5651 sayılı kanunun 8. maddesine ve T.C.K'nın 125. maddesine göre tüm üyelerimiz yaptıkları paylaşımlardan kendileri sorumludur. Sitemiz hakkında yapılacak tüm hukuksal şikayetleri bağlantısından bize ulaşıldıktan en geç 3 (üç) gün içerisinde ilgili kanunlar ve yönetmenlikler çerçevesinde tarafımızca incelenerek, gereken işlemler yapılacak ve site yöneticilerimiz tarafından bilgi verilecektir.