After removing an item from a listview, I would like to select (hilite) the first (or any other) item that remains in the listview. Can anyone help with the syntax.
Which, of course, won't work if you've just removed the ith item of i items! (As I've found to my cost)
I would suggest checking the index of the item you've just deleted against the count of items, and if higher set to count:
Code:
i = lvListView.SelectedItem.Index
lvListView.ListItems.Remove i
If i > lvListView.ListItems.Count Then i = lvListView.ListItems.Count
lvListView.ListItems(i).Selected = True
Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"Why does my program keep showing error messages every time something goes wrong?"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.