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. Drag&Drop problem

Drag&Drop problem

Scheduled Pinned Locked Moved Visual Basic
questionhelp
6 Posts 4 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.
  • T Offline
    T Offline
    The real M
    wrote on last edited by
    #1

    Hi I'm writing a program that has a ListBox control. If the user drags a file and drops it on the listbox, the filename should be added to the list. I'm using the following code:

    Private Sub ListBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragEnter
    If e.Data.GetDataPresent(DataFormats.FileDrop) Then
    e.Effect = DragDropEffects.Copy
    Else
    e.Effect = DragDropEffects.None
    End If
    End Sub

    Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
    Stop 'This is called
    Dim s$ = e.Data.GetData(DataFormats.FileDrop, True) 'Why does this exit the sub?
    Stop 'This not
    '...
    End Sub

    As you can see, I put 2 stop statements in the DragDrop event. The first of them is called and stops debugging, but then e.data.getdata somehow exits the sub, and so nothing happens. Is it even possible that a procedure exits the sub it is called from (without exiting the thread)??? I'm very confused :confused:; I would be grateful to anyone who could give me an explanation for this.

    M A 2 Replies Last reply
    0
    • T The real M

      Hi I'm writing a program that has a ListBox control. If the user drags a file and drops it on the listbox, the filename should be added to the list. I'm using the following code:

      Private Sub ListBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragEnter
      If e.Data.GetDataPresent(DataFormats.FileDrop) Then
      e.Effect = DragDropEffects.Copy
      Else
      e.Effect = DragDropEffects.None
      End If
      End Sub

      Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
      Stop 'This is called
      Dim s$ = e.Data.GetData(DataFormats.FileDrop, True) 'Why does this exit the sub?
      Stop 'This not
      '...
      End Sub

      As you can see, I put 2 stop statements in the DragDrop event. The first of them is called and stops debugging, but then e.data.getdata somehow exits the sub, and so nothing happens. Is it even possible that a procedure exits the sub it is called from (without exiting the thread)??? I'm very confused :confused:; I would be grateful to anyone who could give me an explanation for this.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      What on earth is a stop statement - never used one never even heard of one. Why not just use a breakpoint and inspect the content of e.

      Never underestimate the power of human stupidity RAH

      H 1 Reply Last reply
      0
      • T The real M

        Hi I'm writing a program that has a ListBox control. If the user drags a file and drops it on the listbox, the filename should be added to the list. I'm using the following code:

        Private Sub ListBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
        e.Effect = DragDropEffects.Copy
        Else
        e.Effect = DragDropEffects.None
        End If
        End Sub

        Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
        Stop 'This is called
        Dim s$ = e.Data.GetData(DataFormats.FileDrop, True) 'Why does this exit the sub?
        Stop 'This not
        '...
        End Sub

        As you can see, I put 2 stop statements in the DragDrop event. The first of them is called and stops debugging, but then e.data.getdata somehow exits the sub, and so nothing happens. Is it even possible that a procedure exits the sub it is called from (without exiting the thread)??? I'm very confused :confused:; I would be grateful to anyone who could give me an explanation for this.

        A Offline
        A Offline
        Alan N
        wrote on last edited by
        #3

        Hi, The FileDrop data format is a StringCollection so there should be a runtime error when you try to assign into the string s$. The question is why do you not see the exception? Do you have ON ERROR GOTO 0 anywhere in your code? Alan.

        T 1 Reply Last reply
        0
        • M Mycroft Holmes

          What on earth is a stop statement - never used one never even heard of one. Why not just use a breakpoint and inspect the content of e.

          Never underestimate the power of human stupidity RAH

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

          I'm glad you made that reply. I was going to say exactly the same, but as I do not do much VB it might have passed me by and I didn't want to appear dumb. :-\

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

          M 1 Reply Last reply
          0
          • H Henry Minute

            I'm glad you made that reply. I was going to say exactly the same, but as I do not do much VB it might have passed me by and I didn't want to appear dumb. :-\

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

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            Yeah, just got into the office and about to fire up VB/MSDN to find out what. I used VB since the early 90's (I now use C#) and have never used a stop statement.

            Never underestimate the power of human stupidity RAH

            1 Reply Last reply
            0
            • A Alan N

              Hi, The FileDrop data format is a StringCollection so there should be a runtime error when you try to assign into the string s$. The question is why do you not see the exception? Do you have ON ERROR GOTO 0 anywhere in your code? Alan.

              T Offline
              T Offline
              The real M
              wrote on last edited by
              #6

              Hi, If there was any On Error or Try statement in my code I would understand, but there isn't! :confused: Yes, with a string array it works :-D . Tnx

              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