Merhaba arkadaşlar..Ben bir program yazmaya çalışıyorum.Bu programda dragdrop'a ihtiyaç duydum.Forma 2 adet picturebox ekliyorum ve picturebox1 deki resmi picturebox2 ye sürükleyip kopyalamak istiyorum..Kodlar aşağıdaki gibi.Çalıştırdığımda bir hata almadım ama picturebox2 ye sürükleyemiyorum..Sadece picturebox1 üzerinde mouse efektleri görülüyor.Hatam nerede?Şimdiden yardımlarınız için teşekkürler....
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load PictureBox1.AllowDrop = True PictureBox2.AllowDrop = True
End Sub
Private Sub PictureBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop e.Effect = e.AllowedEffect End Sub
Private Sub PictureBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragEnter If e.Data.GetDataPresent(DataFormats.Bitmap) Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove If e.Button = MouseButtons.Left Then PictureBox1.DoDragDrop(PictureBox1.Image, DragDropEffects.Copy) End If End Sub
Private Sub PictureBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) If (e.Data.GetDataPresent(DataFormats.Bitmap)) Then Me.PictureBox1.Image = CType((e.Data.GetData(DataFormats.Bitmap)), Bitmap) End If End Sub
Private Sub PictureBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox2.DragEnter '' PictureBox1.Image = e.Data.GetData(DataFormats.Bitmap) If (e.Data.GetDataPresent(DataFormats.Bitmap)) Then Me.PictureBox1.Image = CType((e.Data.GetData(DataFormats.Bitmap)), Bitmap) End If End Sub End Class