listview过滤重复

sssskkyy 2008-02-19 11:13:19
过滤listview的重复项,
如: id name id name
1 abc 1 abc
2 edf 2 edf
3 abc ==>> 4 hhh
4 hhh
5 abc
6 edf


行数几千到几万, 需要考虑算法的效率,大家有什么思路, 。。。


...全文
361 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
zyj2014 2012-05-20
  • 打赏
  • 举报
回复
2楼的写法是C#的语言吗,感觉像ASP的写法呢!
a19895161989516 2009-05-28
  • 打赏
  • 举报
回复
哈希表的检索速度 很好 用哈希表表看看
快意一剑 2009-05-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 sssskkyy 的回复:]
HashTable
一项以项往hashtable中读 用hashtable.ContainsKey判断是否存在于hash表中
不存在则Add之.....
[/Quote]

正解
wackyboy 2009-05-27
  • 打赏
  • 举报
回复
delete from table where id not in (select min(id) from table group by name)
zmidl 2009-05-27
  • 打赏
  • 举报
回复
我也有同样的问题 我做的是winform 想要实现 楼主一样的 效果,具体C#代码如何 编写?我找了3天了
没有找到答案。看来这个问题不太好解决吧!!
zmidl 2009-05-27
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 kuaiyiyijian 的回复:]
引用 3 楼 sssskkyy 的回复:
HashTable
一项以项往hashtable中读 用hashtable.ContainsKey判断是否存在于hash表中
不存在则Add之.....


正解
[/Quote]

你等于没说!!
zmidl 2009-05-27
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 wackyboy 的回复:]
SQL codedelete from table where id not in (select min(id) from table group by name)
[/Quote]

不好意思 我没说清楚 我做的是 winform
hanyu0528 2008-11-18
  • 打赏
  • 举报
回复
学习
pingtest 2008-11-18
  • 打赏
  • 举报
回复
Set itmx = SearchUserLV.FindItem("要查找的字符串", 1, , 0) '判断是否有重复,如果没有,插入listview
改为:
Set itmx = Listview1.FindItem("要查找的字符串", 1, , 0) '判断是否有重复,如果没有,插入listview
pingtest 2008-11-18
  • 打赏
  • 举报
回复
这里给你个例子,希望能帮你.
Dim itmx As ListItem
Set itmx = Listview1.FindItem("要查找的字符串", 1, , 0) '判断是否有重复,如果没有,插入listview
If itmx Is Nothing Then
Listview1.ListItems.Add , , Listview1.ListItems.Count + 1 '序号
Listview1.ListItems(Listview1.ListItems.Count).SubItems(1) = "要查找的字符串"
Listview1.ListItems(Listview1.ListItems.Count).SubItems(2) = "其他字符串"
...
End If
pingtest 2008-11-18
  • 打赏
  • 举报
回复
这里给你个例子,希望能帮你.
Dim itmx As ListItem
Set itmx = SearchUserLV.FindItem("要查找的字符串", 1, , 0) '判断是否有重复,如果没有,插入listview
If itmx Is Nothing Then
Listview1.ListItems.Add , , Listview1.ListItems.Count + 1 '序号
Listview1.ListItems(Listview1.ListItems.Count).SubItems(1) = "要查找的字符串"
Listview1.ListItems(Listview1.ListItems.Count).SubItems(2) = "其他字符串"
...
End If
sssskkyy 2008-02-20
  • 打赏
  • 举报
回复
HashTable
一项以项往hashtable中读 用hashtable.ContainsKey判断是否存在于hash表中
不存在则Add之.....
zhuz009 2008-02-19
  • 打赏
  • 举报
回复
不知道有没有什么效率好的方法.

不过我想的方法是

循环第一个表
再循环第二个表
如果第一个表的数据=第二个表的数据
跳出本循环
否则 第一个表的数据添加到第二个表中


刚刚从网上找来的

Dim RngR As Range
Set rng = Selection.SpecialCells(xlCellTypeConstants, 1)
Set DicTmp = CreateObject("Scripting.Dictionary")
For Each RngR In rng
If Not DicTmp.exists(RngR.Value) Then
DicTmp.Add RngR.Value, Empty
End If
Next RngR

Me.ListBox1.List = DicTmp.Keys
Set rng = Nothing
Set DicTmp = Nothing


xiaoqhuang 2008-02-19
  • 打赏
  • 举报
回复
针对listview的数据源过滤呀,数据源是什么类型?

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧