ListView删除重复的vb.net [英] ListView remove duplicates vb.net

查看:59
本文介绍了ListView删除重复的vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我真的需要一些帮助。

我有一个ListView,我想删除duplcate行。

标准:

item.text和subItem



喜欢 -

如果myItem.Text = myItem.Text和myItem.SubItem = myItem.SubItem然后

删除行



提前谢谢你,

Henrik

Hi,

I really need some help here.
I have a ListView where I would like to remove duplcate rows.
The criteria :
item.text and subItem

Like -
if myItem.Text = myItem.Text And myItem.SubItem = myItem.SubItem then
Remove the row

Thank you in advance,
Henrik

推荐答案

你有什么疑问?

迭代(明智地:你要删除物品)您可以使用查找 [< a href =http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.listviewitemcollection.find.aspxtarget =_ blanktitle =New Window> ^ ]获取与当前项目匹配的项目数组,并依次对这样的数组进行处理,删除与子项目匹配的项目。



[更新2]

尝试(我没有测试过):

Dim i as Integer = 0



And what's your doubt about?
Iterating ((wisely: you are removing items) on all the ListView items you could use the Find[^] for getting the array of items matching the current one and, interating in turn on such array, remove the ones matching the subitem too.

[update 2]
Try (I've not tested it):
Dim i as Integer = 0

While (i < lstV_Result.Items.Count) 
      RemoveListViewLine(i, lstV_Result.Items(i).SubItems(1).Text, lstV_Result.Items(i).SubItems(9).Text)
      i = i + 1
End While


Private Sub RemoveListViewLine(ByVal n as Integer, ByVal TextCrit As String, ByVal SubCrit As String)
     Dim li As ListViewItem
     n = n + 1
     While (n < lstV_Result.Items.Count)
          li = lstV_Result.Items(n)
          If li.SubItems(1).Text = TextCrit And li.SubItems(9).Text = SubCrit Then
              lstV_Result.Items.Remove(li)
          Else
              n = n + 1
          End If
     End While
End Sub



[/ update 2]


[/update 2]


这篇关于ListView删除重复的vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆