I have created a two-dimensional array of PictureBoxes, and I want to add a DragDrop event to all the elements of the array.
For x As Integer = 1 To 16
For y As Integer = 1 To 4
p(x, y) = New PictureBox()
p(x, y).Image = My.Resources.Kästchen
p(x, y).Location = New Point(pMain.Left + x * 48, pMain.Top + y * 48)
p(x, y).Size = New Size(48, 48)
p(x, y).Name = "p"+str(x)+str(y)
AddHandler p(x, y).DragDrop, AddressOf p(x,y)_DragDrop
p(x, y).Visible = True
Me.Controls.Add(p(x, y))
Next
Next
I know that there's a similar answer here, but I wasn't able to adapt it to arrays. How do I add the DragDrop Event for all the PictureBoxes, which are created during runtime?