I have a listview that contains 4 listviewitems. I have two buttons - Up and Down.
What I need to do is give the functionality where if you select an item you can click one of the buttons to change
the indexing of the item in the collection.
So if I select item 4 and click the Up button then it will do a .Insert of the 4th item into the 3rd position and move
the 3rd item to the 4th. Also, all the other scenerios that can come up between four items.
I have tried this but I am getting a duplicate 4th item and losing the 3rd item.
Thanks for any help.VB Code:
Dim iSel As Integer = Me.lvwItems.FocusedItem.Index Dim iRemove As Integer = iSel If iSel >= 1 Then 'Its item 2, 3, or 4 iSel = iSel - 1 Dim itm As ListViewItem itm = DirectCast(Me.lvwItems.FocusedItem.Clone, ListViewItem) MessageBox.Show("iSel = " & iSel) Me.lvwItems.Items.Insert(iSel, itm) 'remove the original item Me.lvwItems.Items.Remove(Me.lvwItems.Items.Item(iRemove)) Else 'First item - goes no where :D End If





Reply With Quote