Pergunta

I have a listview with some things in it, and I have a sub that will refresh the listview by deleting everything in it and re-populating it.

However, when the user selects an item and the list refreshes, I wanted to have that same item select itself once more. I accomplished that by doing:

ListView.Items(4).Selected = True 
ListView.Select()

which selects the 5th item in the list view (counting 0). However, when the user presses the up or down keys, the selected item jumps back up to the top item in the list, and I can't find a way around this.

The only search that has come up with anything is here: Arrow keys don't work after programmatically setting ListView.SelectedItem

But I do not understand the responses, I need a dumbed down version or a simpler solution if possible, thank you.

Foi útil?

Solução

Try using the Focused property on an Item. Seems like I may have run into this before.

ListView.Items(4).Focused = True

You may also need to set that same property to False for the first item in the list.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top