ListView: How to get item position 
Author Message
 ListView: How to get item position

I would like to enable the user to move around the listview items and then
retrieve the order the user placed them in. How do I get an items position
in the ListView?
How do I get a list of the item in a list view by position order?

Thanks,
eli



Thu, 24 Jun 1999 03:00:00 GMT  
 ListView: How to get item position

Eli,

The following code, which uses a VScrollBar as a spin control to move an
item up or down in a ListView control.  (The scroll bar has min and max set
to 0 and 2, respectively, and is initialized to 1).  I hope this fragment
gives you some ideas.

Richard Muller

Private Sub ctlVMove_Change()
    Dim nOldValue As Integer: nOldValue = ctlVMove.Value - 1
    Dim nPrevItem: nPrevItem = nCurrentItem
    ctlVMove.Value = 1 ' Causes extra invocation of ctlVMove_Change with
oldval=1

    If nOldValue = -1 Then ' Moving toward top of list
        If nCurrentItem > 1 Then
            nCurrentItem = nCurrentItem - 1
        End If
    Else
        ' Moving toward bottom of list (if nOldValue=2)
        If nOldValue = 1 And nCurrentItem < lvTableNames.ListItems.Count
Then
            nCurrentItem = nCurrentItem + 1
        End If
    End If

    Dim sTemp As String
    Dim liPrev As ListItem: Set liPrev = lvTableNames.ListItems(nPrevItem)
    Dim liCurr As ListItem: Set liCurr =
lvTableNames.ListItems(nCurrentItem)
    liPrev.Selected = False
    liCurr.Selected = True
    sTemp = liPrev.Text
    liPrev.Text = liCurr.Text
    liCurr.Text = sTemp

    lvTableNames.SetFocus

End Sub



Fri, 25 Jun 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Drag an item of Listview to another position of the same ListView

2. ListView: How to get item position?

3. ListView Item position

4. Position Selected Item in a ListView at the top

5. How to get position of ListView item??

6. Getting Index of ListView Items

7. Getting properies item from DTE.Windows.Item(Constants.vsWindowKindProperties)

8. jump listview to the hilight item (selected item)...

9. Any Way To Stop All ListView Items From Blinking While Adding Items

10. Listview: check if an item in current listview

11. changing the background of a listview item in the listview control

12. Listview Control - moving items from one listview to another

 

 
Powered by phpBB® Forum Software