|
-
Aug 4th, 2003, 11:16 PM
#1
Thread Starter
Hyperactive Member
move item in listview
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?
-
Aug 5th, 2003, 08:26 AM
#2
Addicted Member
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
-
Aug 7th, 2003, 05:13 AM
#3
Thread Starter
Hyperactive Member
on click..
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.
Last edited by gmatteson; Aug 7th, 2003 at 05:35 AM.
-
Aug 7th, 2003, 05:24 AM
#4
Addicted Member
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.
-
Aug 7th, 2003, 06:02 AM
#5
Thread Starter
Hyperactive Member
yes
i've select an item, then clicked move up...i noticed that the lvwitem is being refered to the data in column2...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|