Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27212

VS 2010 Random item select in Listview

$
0
0
Hey!
This is my code to select a random item in a listview:
Code:

Dim tmp As Integer
tmp = Rnd() * ListView2.Items.Count - 1
ListView2.Items(tmp).Selected = True
ListView2.EnsureVisible(tmp)

It works fine, but when I use the arrow keys to select another item, the selection jumps to a whole different place...
Like, when I select item A manually, and then use that code to select random item B, and I press an arrow key, the listview jumps to item A again!
Sorry if you don't understand because it's hard to explain.
:wave:

Viewing all articles
Browse latest Browse all 27212

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>