Newbie trying to do Drag and Drop of Images
-
Hello, I'm trying to drag and drop an image (picture) from a column on the left to a column of blank pictures on the right, so I can drop over the blank picture with the original picture. Card game actually. Image1(52) are the pictures of cards on the left Hearts(12) are the hearts suit on the right Clubs(12) also; I haven't finished setting up Spades or Diamonds yet. Here is the code. I cannot get it to work; the images on the left won't move. Just receive a black circle with a diagnal line through it. Any ideas on how I can solve this would be excellent. Much appreciation in advance. Private Sub Image1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Image1.MouseDown Dim Index As Integer Index = 0 For Index = 0 To 51 DoDragDrop(Image1(Index), DragDropEffects.Copy) Next End Sub Private Sub Image1_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles Image1.DragEnter, Hearts.DragEnter, Clubs.DragEnter 'Diamonds.DragEnter, Spades.DragEnter Dim Index As Integer Index = 0 For Index = 0 To 51 DoDragDrop(Image1(Index), DragDropEffects.Move) Next End Sub Private Sub Image1_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles Image1.DragDrop, Hearts.DragDrop, Clubs.DragEnter ' Diamonds.DragEnter, Spades.DragEnter Dim Button As Short If Button = VB6.MouseButtonConstants.LeftButton Then Hearts(12).Image = Image1(0).Image Hearts(11).Image = Image1(1).Image Hearts(10).Image = Image1(2).Image Hearts(9).Image = Image1(3).Image Hearts(8).Image = Image1(4).Image Hearts(7).Image = Image1(5).Image Hearts(6).Image = Image1(6).Image Hearts(5).Image = Image1(7).Image Hearts(4).Image = Image1(8).Image Hearts(3).Image = Image1(9).Image Hearts(2).Image = Image1(10).Image Hearts(1).Image = Image1(11).Image Hearts(0).Image = Image1(12).Image Clubs(12).Image = Image1(25).Image Clubs(11).Image = Image1(24).Image Clubs(10).Image = Image1(23).Image Clubs(9).Image = Image1(22).Image Clubs(8).Image = Image1(21).Image Clubs(7).Image = Image1(20).Image Clubs(6).Image = Image1(19).Image Clubs(5).Image = Image1(18).Image Clubs(4).Image = Image1(17
-
Hello, I'm trying to drag and drop an image (picture) from a column on the left to a column of blank pictures on the right, so I can drop over the blank picture with the original picture. Card game actually. Image1(52) are the pictures of cards on the left Hearts(12) are the hearts suit on the right Clubs(12) also; I haven't finished setting up Spades or Diamonds yet. Here is the code. I cannot get it to work; the images on the left won't move. Just receive a black circle with a diagnal line through it. Any ideas on how I can solve this would be excellent. Much appreciation in advance. Private Sub Image1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Image1.MouseDown Dim Index As Integer Index = 0 For Index = 0 To 51 DoDragDrop(Image1(Index), DragDropEffects.Copy) Next End Sub Private Sub Image1_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles Image1.DragEnter, Hearts.DragEnter, Clubs.DragEnter 'Diamonds.DragEnter, Spades.DragEnter Dim Index As Integer Index = 0 For Index = 0 To 51 DoDragDrop(Image1(Index), DragDropEffects.Move) Next End Sub Private Sub Image1_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles Image1.DragDrop, Hearts.DragDrop, Clubs.DragEnter ' Diamonds.DragEnter, Spades.DragEnter Dim Button As Short If Button = VB6.MouseButtonConstants.LeftButton Then Hearts(12).Image = Image1(0).Image Hearts(11).Image = Image1(1).Image Hearts(10).Image = Image1(2).Image Hearts(9).Image = Image1(3).Image Hearts(8).Image = Image1(4).Image Hearts(7).Image = Image1(5).Image Hearts(6).Image = Image1(6).Image Hearts(5).Image = Image1(7).Image Hearts(4).Image = Image1(8).Image Hearts(3).Image = Image1(9).Image Hearts(2).Image = Image1(10).Image Hearts(1).Image = Image1(11).Image Hearts(0).Image = Image1(12).Image Clubs(12).Image = Image1(25).Image Clubs(11).Image = Image1(24).Image Clubs(10).Image = Image1(23).Image Clubs(9).Image = Image1(22).Image Clubs(8).Image = Image1(21).Image Clubs(7).Image = Image1(20).Image Clubs(6).Image = Image1(19).Image Clubs(5).Image = Image1(18).Image Clubs(4).Image = Image1(17
Do you have the
AllowDrop
property of yourblankImage
set totrue
. Note, I haven't read your code yet. Please edit your original post and put the code between <pre> your code </pre> tags and format it a little, indentation etc., to make it more readable. You are likely to get more responses, if the code is easier to read.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Do you have the
AllowDrop
property of yourblankImage
set totrue
. Note, I haven't read your code yet. Please edit your original post and put the code between <pre> your code </pre> tags and format it a little, indentation etc., to make it more readable. You are likely to get more responses, if the code is easier to read.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
Thanks for the advice. I didn't have the attribute AllowDrop set to True, so I changed it, but it didn't make a difference. I still cannot get the images, image(0-51) on the left to move or even be selected. I am trying different things, but here is the code and some edited out for testing purposes. By the way, I formatted this with indentation, but when I post it, it comes up all the way to the left. Any way I can change this? Private Sub Image1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Image1.MouseDown Dim Index As Integer For Index = 0 To 51 Image1(Index).DoDragDrop(Image1(Index), DragDropEffects.Copy) Image1(Index).DoDragDrop(Image1(Index), DragDropEffects.Move) ' DoDragDrop(Image1(Index), DragDropEffects.Move) Next End Sub Private Sub _Image1_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles Image1.DragEnter, Hearts.DragEnter, Clubs.DragEnter 'Diamonds.DragEnter, Spades.DragEnter Dim Index As Integer For Index = 0 To 51 Image1(Index).DoDragDrop(Image1(Index), DragDropEffects.Copy) Image1(Index).DoDragDrop(Image1(Index), DragDropEffects.Move) Next ' Dim Index As Integer ' Index = 0 ' For Index = 0 To 51 ' If (e.Data.GetDataPresent(DataFormats.Bitmap)) Then ' e.Effect = DragDropEffects.Move ' End If ' Next End Sub Pri
-
Thanks for the advice. I didn't have the attribute AllowDrop set to True, so I changed it, but it didn't make a difference. I still cannot get the images, image(0-51) on the left to move or even be selected. I am trying different things, but here is the code and some edited out for testing purposes. By the way, I formatted this with indentation, but when I post it, it comes up all the way to the left. Any way I can change this? Private Sub Image1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Image1.MouseDown Dim Index As Integer For Index = 0 To 51 Image1(Index).DoDragDrop(Image1(Index), DragDropEffects.Copy) Image1(Index).DoDragDrop(Image1(Index), DragDropEffects.Move) ' DoDragDrop(Image1(Index), DragDropEffects.Move) Next End Sub Private Sub _Image1_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles Image1.DragEnter, Hearts.DragEnter, Clubs.DragEnter 'Diamonds.DragEnter, Spades.DragEnter Dim Index As Integer For Index = 0 To 51 Image1(Index).DoDragDrop(Image1(Index), DragDropEffects.Copy) Image1(Index).DoDragDrop(Image1(Index), DragDropEffects.Move) Next ' Dim Index As Integer ' Index = 0 ' For Index = 0 To 51 ' If (e.Data.GetDataPresent(DataFormats.Bitmap)) Then ' e.Effect = DragDropEffects.Move ' End If ' Next End Sub Pri
-
ymilan wrote:
I think I figured it out
Good for you well done. :thumbsup: For future reference, on the formatting thing there are two options 1. Type <pre> on the line above your code, and </pre> on the line after. 2. Next time tou post a message look just below the typing area, on the line above the emoticons, see the
code block
, well either click on it first (it puts the tags in for you) then paste your code between the tags, or paste your code, select it all then click the code block widget.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”