[2005] Drag & Drop within ListBox - Part 2
Hello -
The other day I had an inquiry on how to implement drag and drop to rearrange items within a listbox (http://www.vbforums.com/showthread.php?t=492618) and thanks to Rykler, I have that working fine.
Part 2 is: how do I extend this so that the drag & drop can take place while scrolling? (In other words, if the spot I want to drop the item at is not currently visible in the listbox)?
I know it has something to do with detecting when the mouse is resting on the top or bottom edge for a certain amount of time, implement an auto-scrolling operation. But the precise code eludes me ...
Re: [2005] Drag & Drop within ListBox - Part 2
This will scroll the listbox if you drag an item outside of the form. If it isn't what you need I hope it will atleast get you started.
Code:
Private Sub ListBox1_QueryContinueDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.QueryContinueDragEventArgs) Handles ListBox1.QueryContinueDrag
If Control.MousePosition.Y < Me.DesktopBounds.Top Then
ListBox1.TopIndex = ListBox1.TopIndex + 1
ElseIf Control.MousePosition.Y > Me.DesktopBounds.Bottom Then
ListBox1.TopIndex = ListBox1.TopIndex - 1
End If
End Sub
Re: [2005] Drag & Drop within ListBox - Part 2
Thanks for this - I was only able to play with this briefly, but I could not get it working; I also tried some quick modifications that also did not work. But I will play around with it some more.
Meanwhile, if you or someone else has something more definitive, that code would certainly be welcome :)