Listview Scroll
ok, on a button click how could i have the listview selected item jump to the next. so if there was a list view with 3 items and the second was selected. On a button clickhow could i make it jump to the third?
-T
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
int current = this.listView1.SelectedIndices[0];
int next = current == this.listView1.Items.Count - 1 ? 0 : current + 1;
this.listView1.Focus();
this.listView1.Items[next].Selected = true;
this.listView1.Items[current].Selected = false;
note: this will jump back to the first one when the last one was selected
r0ckbaer
Junior Poster in Training
55 posts since Dec 2003
Reputation Points: 13
Solved Threads: 6
int current = this.listView1.SelectedIndices[0];
int next = current == this.listView1.Items.Count - 1 ? 0 : current + 1;
this.listView1.Focus();
this.listView1.Items[next].Selected = true;
this.listView1.Items[current].Selected = false;
note: this will jump back to the first one when the last one was selected
thanks that worked. And to make it go the other way is a very simple tweak :)
Thanks again
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99