Hi, friends!
I intend to create a program which will have 16 picture boxes inside form separated into two rows. Controls in the first row are named as:
pbox1, pbox2.... pbox8
in the second row:
pbox11, pbox22, pbox33.... pbox88
I need to drag any icon from the upper row to lower.
I tried to do that this way: (3 controls in two rows)
Unfortunately, it doesn't work correctly.
If I drag 1'st pic box from upper row to the bottom one, it fills 1'st and 2'nd lower picbox with the same picture in the same time. The same situation is with 2'nd upper pic box. The 3'rd upper picbox doesn't work at all.
How to solve this?
Thx in advance
I intend to create a program which will have 16 picture boxes inside form separated into two rows. Controls in the first row are named as:
pbox1, pbox2.... pbox8
in the second row:
pbox11, pbox22, pbox33.... pbox88
I need to drag any icon from the upper row to lower.
I tried to do that this way: (3 controls in two rows)
Code:
Public Class Form1
Dim boolMouseDown As Boolean
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
pbox22.AllowDrop = True
pbox11.AllowDrop = True
pbox33.AllowDrop = True
End Sub
Private Sub pbox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbox1.MouseDown
If Not pbox1.Image Is Nothing Then
boolMouseDown = True
End If
End Sub
Private Sub pbox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbox1.MouseMove
If boolMouseDown Then
pbox1.DoDragDrop(pbox1.Image, DragDropEffects.Copy Or DragDropEffects.Move)
End If
boolMouseDown = False
End Sub
Private Sub pbox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbox2.MouseDown
If Not pbox2.Image Is Nothing Then
boolMouseDown = True
End If
End Sub
Private Sub pbox2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbox2.MouseMove
If boolMouseDown Then
pbox2.DoDragDrop(pbox2.Image, DragDropEffects.Copy Or DragDropEffects.Move)
End If
boolMouseDown = False
End Sub
Private Sub pbox3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbox3.MouseDown
If Not pbox3.Image Is Nothing Then
boolMouseDown = True
End If
End Sub
Private Sub pbox3_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbox3.MouseMove
If boolMouseDown Then
pbox3.DoDragDrop(pbox1.Image, DragDropEffects.Copy Or DragDropEffects.Move)
End If
boolMouseDown = False
End Sub
Private Sub pbox11_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pbox11.DragDrop
pbox11.Image = e.Data.GetData(DataFormats.Bitmap)
End Sub
Private Sub pbox11_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pbox11.DragEnter
If e.Data.GetDataPresent(DataFormats.Bitmap) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub pbox22_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pbox11.DragDrop
pbox22.Image = e.Data.GetData(DataFormats.Bitmap)
End Sub
Private Sub pbox22_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pbox22.DragEnter
If e.Data.GetDataPresent(DataFormats.Bitmap) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub pbox33_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pbox33.DragDrop
pbox22.Image = e.Data.GetData(DataFormats.Bitmap)
End Sub
Private Sub pbox33_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pbox33.DragEnter
If e.Data.GetDataPresent(DataFormats.Bitmap) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
End Class
If I drag 1'st pic box from upper row to the bottom one, it fills 1'st and 2'nd lower picbox with the same picture in the same time. The same situation is with 2'nd upper pic box. The 3'rd upper picbox doesn't work at all.
How to solve this?
Thx in advance