Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Newbie trying to do Drag and Drop of Images

Newbie trying to do Drag and Drop of Images

Scheduled Pinned Locked Moved Visual Basic
databasegame-dev
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    ymilan
    wrote on last edited by
    #1

    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

    H 1 Reply Last reply
    0
    • Y ymilan

      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

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      Do you have the AllowDrop property of your blankImage set to true. 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.”

      Y 1 Reply Last reply
      0
      • H Henry Minute

        Do you have the AllowDrop property of your blankImage set to true. 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.”

        Y Offline
        Y Offline
        ymilan
        wrote on last edited by
        #3

        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

        Y 1 Reply Last reply
        0
        • Y ymilan

          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

          Y Offline
          Y Offline
          ymilan
          wrote on last edited by
          #4

          Nevermind on the format, I think I figured it out.

          H 1 Reply Last reply
          0
          • Y ymilan

            Nevermind on the format, I think I figured it out.

            H Offline
            H Offline
            Henry Minute
            wrote on last edited by
            #5

            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.”

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups