Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Reorder items within a listbox via drag and drop

  1. #1

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

    [RESOLVED] [2005] Reorder items within a listbox via drag and drop

    Does anyone have an example of how to do this in VB.NET? There are plenty of examples out there for VB6, but I have not yet been able to find this for .NET.
    Last edited by BruceG; Oct 15th, 2007 at 08:15 PM. Reason: resolved
    "It's cold gin time again ..."

    Check out my website here.

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2005] Reorder items within a listbox via drag and drop

    Quote Originally Posted by BruceG
    Does anyone have an example of how to do this in VB.NET? There are plenty of examples out there for VB6, but I have not yet been able to find this for .NET.
    Hi,

    Here's a link how to do it in C#, perhaps you can change it to VB.Net.

    http://psiman.wordpress.com/2006/12/...reablelistbox/

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3

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

    Re: [2005] Reorder items within a listbox via drag and drop

    Thanks, I appreciate the link, but that's a custom control and uses WPF. It is a little heavier than what I was looking for ...
    "It's cold gin time again ..."

    Check out my website here.

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

    Re: [2005] Reorder items within a listbox via drag and drop

    Here is an example I put together real quick it should help you out.
    Code:
    Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
            ListBox1.Items.Insert(ListBox1.IndexFromPoint(ListBox1.PointToClient(New Point(e.X, e.Y))), e.Data.GetData(DataFormats.Text))
            ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
        End Sub
    
        Private Sub ListBox1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragOver
            e.Effect = DragDropEffects.Move
        End Sub
    
        Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
            ListBox1.DoDragDrop(ListBox1.Text, DragDropEffects.All)
        End Sub

  5. #5

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

    Re: [2005] Reorder items within a listbox via drag and drop

    BEAUTIFUL!!! Thank you very much.
    "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