Results 1 to 3 of 3

Thread: Moving items in a listbox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Singapore
    Posts
    24

    Arrow

    Is there any way i can reposition items in a listbox by dragging??

  2. #2
    Guest
    Try this:


    Code:
    Private Sub Form_Load()
        List1.Clear
    
    
        For I = 0 To 10
            List1.AddItem "Item" & I
        Next I
    End Sub
    
    
    Private Sub List1_KeyDown(KeyCode As Integer, Shift As Integer)
    
    
        With List1
            If .ListCount = -1 Then Exit Sub
    
    
            If KeyCode = vbKeyDown Then
                If .ListIndex + 1 = .ListCount Then Exit Sub
                Tmp = .ListIndex
                .AddItem .List(.ListIndex), .ListIndex + 2
                .RemoveItem .ListIndex
                .Refresh
                .ListIndex = Tmp
            End If
    
    
            If KeyCode = vbKeyUp Then
                If .ListIndex = 0 Then Exit Sub
                Tmp = .ListIndex
                .AddItem .List(.ListIndex), Tmp - 1
                .RemoveItem Tmp + 1
                .Refresh
                .ListIndex = Tmp
            End If
        End With
    End Sub

  3. #3
    Guest

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