简体   繁体   English

从ListView删除项目时,如何在VB.NET中突出显示替换项目的项目?

[英]When removing an item from a ListView, how do I highlight the item that relaces it in VB.NET?

I have a ListView in my project that has dynamically added/edited/deleted items. 我的项目中有一个ListView,它具有动态添加/编辑/删除的项目。 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 ). 我尝试仅存储已删除项目的索引,然后在其中突出显示该项目( list.Items(index).Selected = True )。 This works well unless the item deleted was the last item in the ListView (both literally and sequentially). 除非删除的项目是ListView中的最后一个项目(无论是字面还是顺序),否则此方法都很好。 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. 我感到非常愚蠢,但是今天我的大脑崩溃了。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM