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
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
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
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
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.