Results 1 to 3 of 3

Thread: [2005] Drag & Drop within ListBox - Part 2

  1. #1

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    [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 ...
    "It's cold gin time again ..."

    Check out my website here.

  2. #2
    Lively Member
    Join Date
    Aug 2007
    Posts
    66

    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

  3. #3

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    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
    "It's cold gin time again ..."

    Check out my website here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width