I have a ListView in my project that has dynamically added/edited/deleted items. When the user deletes an item, I want the item that replaces the deleted item to be highlighted. I tried simply storing the deleted item's index then highlighting the item there (list.Items(index).Selected = True
). This works well unless the item deleted was the last item in the ListView (both literally and sequentially). I'm having iss开发者_C百科ues today with logic and can't quite come up with code that checks for these kinds of cases.
Could anyone help me? I feel incredibly stupid but my brain just falls apart today.
IF index = list.Items.Count THEN
' deleted index was at end of list and do your thing
ELSE
list.Items(index).Selected = True
END IF
精彩评论