Hack Forums
[.NET] Check if item exist - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Check if item exist (/showthread.php?tid=4951335)



Check if item exist - denn1s - Aug 16, 2015

Hello, My question is how to see if a item exist in a listview?
And when it exist get the sub column value.


Thanks alot


Dennis


* - SL x TnT - Aug 16, 2015

Aren't you doing that backwards? Think of the problem without using any controls.

Use a List to hold all your objects. Create a custom class, if you need to. Then all you need to do is loop through that list for whatever you're looking for.


* - hacking18 - Aug 16, 2015

Code
Dim item as ListviewItem
for each item in Listview1.Items
If (item.SubItems(0).Text).ToString.Equals("name of the item you want to look for") Then  
      MsgBox("item exists")  
      Exit For
      End If  
      Next



* - nathan72389 - Aug 16, 2015

if only there was a find method.

[Image: lkEmUec.png]