|
-
Jan 18th, 2018, 07:50 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Event for Detecting Failed Drag/Drop
In my application code is executed during drag/drop which draws pretty cool looking x's across controls that won't accept a drop. Everything works fine if the drag/drop is succesful because i erase the x's in the dragdrop event, but if the user lets go of the left mouse button over a control which doesn't accept a drop then the x's stay on the screen I need an event which is triggered if the drag drop fails. I tried using a simple mouseup event for the entire form but it hasn't worked for some reason.
Any help would be appreciated. Thanx!
Last edited by neef; Jan 27th, 2018 at 08:21 PM.
Intermediate Level Programmer Extraordinaire 
-
Jan 18th, 2018, 08:16 PM
#2
Re: Event for Detecting Failed Drag/Drop
I've not done a lot of drag-n-drop so I'm no expert but I'd start by looking at the GiveFeedback and QueryContinueDrag events to see whether they might be of use. That said, can you not just handle DragDrop for those other controls and perform the cleanup without performing the drop?
-
Jan 27th, 2018, 08:19 PM
#3
Thread Starter
Hyperactive Member
Re: Event for Detecting Failed Drag/Drop
Finally got back to this issue and wanted to report that jmcilhinney's suggested event QueryContinueDrag was the best option for my situation. I also added some code (borrowed from another site) that handled if the user moves the mouse off the form.
Code:
Private Sub UCHeadCoachSchedule_QueryContinueDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.QueryContinueDragEventArgs) Handles MyBase.QueryContinueDrag 'Other dragdrop controls
Dim lb As CCTrainingLabel = CType(sender, CCTrainingLabel)
If (lb IsNot Nothing) Then
Dim f As Form = Me.FindForm
' Cancel the drag if the mouse moves off the form or drops outside a eligible control
If Control.MousePosition.X < f.DesktopBounds.Left Or Control.MousePosition.X > f.DesktopBounds.Right Or Control.MousePosition.Y < f.DesktopBounds.Top Or Control.MousePosition.Y > f.DesktopBounds.Bottom Or Control.MouseButtons = Windows.Forms.MouseButtons.None Then
e.Action = DragAction.Cancel
' Other cleanup code
End If
End if
End Sub
Intermediate Level Programmer Extraordinaire 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|