문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top