select next item then double click event in a listview

Lanc1988

Contributor
Joined
Nov 27, 2003
Messages
508
Select next item in a listview

I have a listview and when an item is double clicked it displays a group box with labels where it loads certain things depending on what is selected when something is doubleclicked..

I would like to add a next and previous button to the group box so the user can just go to that instead of closing the group box to see the listview again to double click something new.

So I need the code to select the next item in a listview.. I tried stuff like listview1.selecteditem.next but that kind of code doesn't work.
 
Last edited:
Edited post:

I do not need it to trigger a double click event.. i only need the code to select the next and previous items in the listview.
 
Doing it by head.

PHP:
//get the index of the currently selected item
int previousSelectedIndex = myListView.SelectedItems[0].index;
//unselect the item, should not be necessary if multiselect is false.
myListVew.SelectedItems[0].Selected = false;
//select the next item, for selecting the previous item you would do - 1
myListView.Items[previousSelectedIndex + 1].Selected = true;

Off course this doesnt prevent errors in case you already selected the last item in the list, nor does it cope with having more (or less) than one item selected, and I dont really know what happens with the index if you use any form of sorting. Other than that it might work ;)
 
Back
Top