codice:
Public Class Form1
'array di PictureBox
Private pbx() As PictureBox
Private vett() As PictureBox
'indice dell'array
Private i As Integer = 0
Private indice As Integer = 0
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'abiliti il Panel a ricevere controlli con il DRAG & Drop
Panel1.AllowDrop = True
Panel2.AllowDrop = True
Panel3.AllowDrop = True
Panel4.AllowDrop = True
Panel5.AllowDrop = True
End Sub
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
'consente di iniziare un'operazione di trascinamento, con conseguente copia, del contenuto della picturebox scelta
sender.DoDragDrop(sender.Image, DragDropEffects.Copy)
PictureBox1.Image = Nothing
End Sub
Private Sub PictureBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseDown
'consente di iniziare un'operazione di trascinamento, con conseguente copia, del contenuto della picturebox scelta
sender.DoDragDrop(sender.Image, DragDropEffects.Copy)
PictureBox2.Image = Nothing
End Sub
Private Sub PictureBox3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox3.MouseDown
'consente di iniziare un'operazione di trascinamento, con conseguente copia, del contenuto della picturebox scelta
sender.DoDragDrop(sender.Image, DragDropEffects.Copy)
PictureBox3.Image = Nothing
End Sub
Private Sub PictureBox4_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox4.MouseDown
'consente di iniziare un'operazione di trascinamento, con conseguente copia, del contenuto della picturebox scelta
sender.DoDragDrop(sender.Image, DragDropEffects.Copy)
PictureBox4.Image = Nothing
End Sub
Private Sub PictureBox5_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox5.MouseDown
'consente di iniziare un'operazione di trascinamento, con conseguente copia, del contenuto della picturebox scelta
sender.DoDragDrop(sender.Image, DragDropEffects.Copy)
PictureBox5.Image = Nothing
End Sub
Private Sub Panel1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragEnter
'abilita l'effetto copia
e.Effect = DragDropEffects.Copy
End Sub
Private Sub Panel2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel2.DragEnter
'abilita l'effetto copia
e.Effect = DragDropEffects.Copy
End Sub
Private Sub Panel3_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel3.DragEnter
'abilita l'effetto copia
e.Effect = DragDropEffects.Copy
End Sub
Private Sub Panel4_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel4.DragEnter
'abilita l'effetto copia
e.Effect = DragDropEffects.Copy
End Sub
Private Sub Panel5_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel5.DragEnter
'abilita l'effetto copia
e.Effect = DragDropEffects.Copy
End Sub
Private Sub Panel1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragDrop
ReDim Preserve pbx(indice)
Dim a As New PictureBox
pbx(indice) = New PictureBox
pbx(indice).Name = "immagine" & indice.ToString
pbx(indice).Location = New System.Drawing.Point(8, 8)
'recupera l'immagine trascinata e la inserisce nella picturebox
pbx(indice).Image = e.Data.GetData(DataFormats.Bitmap)
pbx(indice).Size = New Size(240, 174)
pbx(indice).SizeMode = PictureBoxSizeMode.StretchImage
a = pbx(indice)
Me.Panel1.Controls.Add(a)
End Sub
Private Sub Panel2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel2.DragDrop
ReDim Preserve vett(i)
Dim b As New PictureBox
vett(i) = New PictureBox
vett(i).Name = "im" & i.ToString
vett(i).Location = New System.Drawing.Point(8, 8)
'recupera l'immagine trascinata e la inserisce nella picturebox
vett(i).Image = e.Data.GetData(DataFormats.Bitmap)
vett(i).Size = New Size(240, 174)
vett(i).SizeMode = PictureBoxSizeMode.StretchImage
b = vett(i)
Me.Panel2.Controls.Add(b)
End Sub
Private Sub Panel3_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel3.DragDrop
ReDim Preserve vett(i)
Dim b As New PictureBox
vett(i) = New PictureBox
vett(i).Name = "im" & i.ToString
vett(i).Location = New System.Drawing.Point(8, 8)
'recupera l'immagine trascinata e la inserisce nella picturebox
vett(i).Image = e.Data.GetData(DataFormats.Bitmap)
vett(i).Size = New Size(240, 174)
vett(i).SizeMode = PictureBoxSizeMode.StretchImage
b = vett(i)
Me.Panel3.Controls.Add(b)
End Sub
Private Sub Panel4_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel4.DragDrop
ReDim Preserve vett(i)
Dim b As New PictureBox
vett(i) = New PictureBox
vett(i).Name = "im" & i.ToString
vett(i).Location = New System.Drawing.Point(8, 8)
'recupera l'immagine trascinata e la inserisce nella picturebox
vett(i).Image = e.Data.GetData(DataFormats.Bitmap)
vett(i).Size = New Size(240, 174)
vett(i).SizeMode = PictureBoxSizeMode.StretchImage
b = vett(i)
Me.Panel4.Controls.Add(b)
End Sub
Private Sub Panel5_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel5.DragDrop
ReDim Preserve vett(i)
Dim b As New PictureBox
vett(i) = New PictureBox
vett(i).Name = "im" & i.ToString
vett(i).Location = New System.Drawing.Point(8, 8)
'recupera l'immagine trascinata e la inserisce nella picturebox
vett(i).Image = e.Data.GetData(DataFormats.Bitmap)
vett(i).Size = New Size(240, 174)
vett(i).SizeMode = PictureBoxSizeMode.AutoSize
b = vett(i)
Me.Panel5.Controls.Add(b)
End Sub