Drag کردن عکس از یک pictureBox به یک pictureBox دیگر
دو کنترل pictureBox بر روی فرم قرار دهید :
سپس کدهای زیر را در رویدادهای مربوطه بنویسید :
using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.pictureBox2.AllowDrop = true; } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left & pictureBox1.Image != null) { 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)) { pictureBox2.Image = (Image)e.Data.GetData(DataFormats.Bitmap); } } } }