locked
Drag and Drop RRS feed

  • Question

  • tengo 30 picturebox, para los cuales quiero mover de un picturebox Principal a cualquiera de esas 30 picturebox que tengo ordenadas en forma de matriz.

    ya intente solo configurando la primera y la principal pero no me funciona.

    aqui esta el codigo que uso:

    Private Sub Lista_Load(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.Load
            CPrincipal.AllowDrop = True
            C1_1.AllowDrop = True

    end sub

    Private Sub PictureBox_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles CPrincipal.DragDrop, C1_1.DragDrop
            If Not e.Data.GetDataPresent(DataFormats.Bitmap) Then Exit Sub

            e.Effect = DragDropEffects.Move

            Dim ctlCurrent As PictureBox = DirectCast(sender, PictureBox)
            ctlCurrent.Image = DirectCast(e.Data.GetData(DataFormats.Bitmap), Image)
        End Sub

        Private Sub PictureBox_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles CPrincipal.DragEnter, C1_1.DragEnter
            If e.Data.GetDataPresent(DataFormats.Bitmap) Then

                e.Effect = e.AllowedEffect And DragDropEffects.Move
            End If
        End Sub

        Private Sub PictureBox_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CPrincipal.MouseMove, C1_1.MouseMove
            If e.Button = 0 Then Exit Sub

            Dim ctlCurrent As PictureBox = DirectCast(sender, PictureBox)

            Dim objDO As New DataObject
            objDO.SetData(DataFormats.Bitmap, ctlCurrent.Image)

            Dim effect As DragDropEffects = DragDropEffects.Copy Or DragDropEffects.Move
            effect = ctlCurrent.DoDragDrop(objDO, effect)

            If effect = DragDropEffects.Move Then
                ctlCurrent.Image = Nothing
            End If
        End Sub

    y e intentado con este tambien:

    Private Sub Lista_Load(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.Load
            CPrincipal.AllowDrop = True
            C1_1.AllowDrop = True

    end sub

     Private Sub CPrincipal_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CPrincipal.MouseMove

            If (e.Button = Windows.Forms.MouseButtons.Left) Then
                CPrincipal.DoDragDrop(CPrincipal.Image, DragDropEffects.All)
            End If


        End Sub

        Private Sub C1_1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles C1_1.DragEnter
            If (e.Data.GetDataPresent(DataFormats.Bitmap)) Then
                e.Effect = DragDropEffects.Copy
            Else
                e.Effect = DragDropEffects.None
            End If
        End Sub

        Private Sub C1_1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles C1_1.DragDrop

            If (e.Data.GetDataPresent(DataFormats.Bitmap)) Then

                C1_1.Image = e.Data.GetData(DataFormats.Bitmap)

            End If

    agradecere mucho su ayuda

    • Moved by Mike Feng Thursday, June 6, 2013 10:24 AM
    Thursday, May 30, 2013 4:49 PM

Answers

All replies