views:

24

answers:

1

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 issues 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.

+3  A: 
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
Kyra
Thanks! I don't know why I couldn't get that. I think I was over complicating it way too much. Works perfectly.
Steven
No problem. We all have times when our minds just don't want to work :)
Kyra