FUN?ÃO SELECIONAR COM DRAG AND DROP - PICTUREBOX P

VERONICAVERONIC 09/08/2017 22:27:37
#475721
Olá

Estou tentando fazer um formulário de seleção no meu sistema.

A ideia é a seguinte: o usuário terá imagens na tela (que serão exibidas em PictureBox). Essas figuras representam as opções de seleção que ele tem. Para selecionar uma ou mais opções o usuário tem que clicar na imagem e arrastá-la para dentro de um Painel (Panel). Cada PictureBox receberá um nome específico que a identificará.

A tela de exemplo onde estou tentando aplicar isso está na imagem em anexo.

Consegui fazer essa funcionalidade de clicar e arrastar para o Panel usando o código em anexo, isso está funcionando.

Mas agora preciso saber como faço para identificar qual imagem foi arrastada para dentro do panel?? Pois para cada uma delas tenho que executar uma tarefa diferente no programa.

Desde de já agradeço a atenção.

O código é este:
  Public Class Form2
Public Property SizeMode As PictureBoxSizeMode
Private MouseIsDown As Boolean = False

Dim pos As Integer = 10

Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load, Pic1.MouseEnter, Pic1.DragLeave

PanelDrop.AllowDrop = True
End Sub


Private Sub Pic1_MouseDown(sender As Object, e As MouseEventArgs) Handles Pic1.MouseDown
If Not Pic1.Image Is Nothing Then
[ô] Set a flag to show that the mouse is down.
MouseIsDown = True
End If

End Sub

Private Sub Pic2_MouseDown(sender As Object, e As MouseEventArgs) Handles Pic2.MouseDown
If Not Pic2.Image Is Nothing Then
[ô] Set a flag to show that the mouse is down.
MouseIsDown = True
End If
End Sub

Private Sub Pic3_MouseDown(sender As Object, e As MouseEventArgs) Handles Pic3.MouseDown
If Not Pic3.Image Is Nothing Then
[ô] Set a flag to show that the mouse is down.
MouseIsDown = True
End If

End Sub



Private Sub Pic1_MouseMove(sender As Object, e As MouseEventArgs) Handles Pic1.MouseMove
If MouseIsDown Then
[ô] Initiate dragging and allow either copy
Pic1.DoDragDrop(Pic1.Image, DragDropEffects.Copy Or
DragDropEffects.Move)
End If
MouseIsDown = False
End Sub

Private Sub Pic2_MouseMove(sender As Object, e As MouseEventArgs) Handles Pic2.MouseMove
If MouseIsDown Then
[ô] Initiate dragging and allow either copy or move.
Pic2.DoDragDrop(Pic2.Image, DragDropEffects.Copy Or
DragDropEffects.Move)
End If
MouseIsDown = False

End Sub

Private Sub Pic3_MouseMove(sender As Object, e As MouseEventArgs) Handles Pic3.MouseMove
If MouseIsDown Then
[ô] Initiate dragging and allow either copy or move.
Pic3.DoDragDrop(Pic3.Image, DragDropEffects.Copy Or
DragDropEffects.Move)

End If
MouseIsDown = False
End Sub


Private Sub PanelDrop_DragEnter(sender As Object, e As DragEventArgs) Handles PanelDrop.DragEnter
If e.Data.GetDataPresent(DataFormats.Bitmap) Then
[ô]Copia a imagem do picture box quando clico e arrasto
e.Effect = DragDropEffects.Copy
End If

End Sub



Private Sub PanelDrop_DragDrop(sender As Object, e As DragEventArgs) Handles PanelDrop.DragDrop

[ô]Size of picturebox inside the panel
Dim u As New PictureBox
u.Width = 100
u.Height = 100
u.BackColor = Color.BlueViolet
u.Left = pos
u.Top = 10
pos += 120

[ô]Set the SizeMode to center the image.
u.SizeMode = PictureBoxSizeMode.StretchImage


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

[ô]Um condição IF aqui? COmo saber o nome da picturebox selecionada??


[ô]Insert picture in the Panel
PanelDrop.Controls.Add(u)
End Sub


End Class
KERPLUNK 10/08/2017 08:54:32
#475725
Já verificou o que contém nos parâmetros do método?
VERONICAVERONIC 05/12/2017 19:46:22
#478288
Solução aqui: http://www.vbforums.com/showthread.php?851497-RESOLVED-Selection-Drag-and-Drop-a-PictureBox-to-a-Panel&highlight=
Tópico encerrado , respostas não são mais permitidas