I have items in a listview and I want to know how to add 2 buttons one that makes the item move up in the list and one that make the item move down in the list. I figure out how to do it with listboxes but I cant figure out or find where to do it for list views and help is appreciated.
Check out the Listview.Items.Remove and Listview.Items.Insert methods:
listView1.Items.Remove(selectedItem);
listView1.Items.Insert(newIndex, selectedItem);
Dealing with the changing index (when you remove a ListViewItem, the indexes of the list items which come after the selected item all change by one) can be a pain. Also, you will need to manage what happens when you promote or demote an item past the top or lower bounds of the item indexes.
Hope that gets you started.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With