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