is there a way to move an item "up" in a listview?
if the item is number 4 on the list, on button click, can i move that item up to number 3 on the list?
Printable View
is there a way to move an item "up" in a listview?
if the item is number 4 on the list, on button click, can i move that item up to number 3 on the list?
VB Code:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click ListView1.Items.Add("Item " & ListView1.Items.Count) End Sub Private Sub btnUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUp.Click If ListView1.SelectedItems.Count = 1 Then Dim lvItem As ListViewItem = ListView1.SelectedItems(0) Dim newIndex As Integer = lvItem.Index - 1 If newIndex >= 0 Then ListView1.Items.Remove(lvItem) ListView1.Items.Insert(newIndex, lvItem) End If End If End Sub
when i click the move up button, nothing seems to happen to the items in the listview....it just blinks then thats it. sorry for the late reply, i've been gone for a day. it's also a two column listview if that will help at all. thanks again.
works for me.....
Have you selected an item before you click up?
Try a new test project with just a form, a listview and two buttons.
i've select an item, then clicked move up...i noticed that the lvwitem is being refered to the data in column2...