Results 1 to 2 of 2

Thread: dragdrop with a listview

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305
    I've got a listview in report mode (it's a small table, really), and I want the user to be able to change the order of the rows. They should be allowed to click on row 5, drag it up a ways, and drop it between rows 1 and 2 (those are arbitrary numbers). All I want is to allow dragdrop support to the report mode of the listview, but it's eluding me.

    Thanks in advance,

    bob

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Bob
    this isn't quite a drag and drop but clicking an item selects it and then clicking another item places the first item below the second one

    does that make sense?

    Code:
    Option Explicit
    Dim TheItem As ListItem
    Dim TheItemIndex As Integer
    
    Private Sub Form_Load()
    Dim itmx As ListItem
    Dim i As Integer
    For i = 0 To 6
    Set itmx = ListView1.ListItems.Add(, , "Item " & i)
    
    Next i
    End Sub
    
    Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim itmx As ListItem
    If TheItemIndex = 0 Then
      TheItemIndex = Item.Index
      Set TheItem = Item
      ListView1.MousePointer = ccCross'change this for an icon
    Else
      'already set
      i = Item.Index
      ListView1.ListItems.Remove TheItemIndex
      Set itmx = ListView1.ListItems.Add(i + 1)
      itmx = TheItem
       ListView1.MousePointer = ccDefault
      TheItemIndex = 0
    End If
    
    
    End Sub
    Mark
    -------------------

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