Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
PictureBox Drag - Drop
#1
İki PictureBox arasında sürükle bırak yoluyla resim aktarmaya ilişkin, internette denk geldiğim güzel bir örnek.

//In the Form Load
//Set AllowDrop of the Target PictureBox to true as this property cannot be set in the Designer (Form Load)
Kod:
this.pictureBox2.AllowDrop = true;


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


//Target PictureBox
//Drag Drop Effects
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;
}


//Set the image to be the dragged image.
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));  
}
}
Cevapla


Hızlı Menü:


Konuyu Okuyanlar: 1 Ziyaretçi