Hack Forums
[.NET] Compare item to SubItems 2 different listview - 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] Compare item to SubItems 2 different listview (/showthread.php?tid=5153386)



Compare item to SubItems 2 different listview - OneTXxL - Jan 30, 2016

Hello thank you in advance for your help, say my columns contains the ListView1
| Title | length | Artist | album | year |

and that contains listview2
| Album | length | weight | Directory. |

I would compare the name of the album and find the ListView1
listview2 album and then recover the weight.
Thanks for your help.


* - Nikola Тesla - Feb 3, 2016

PHP Code

<?php 
For Each item As ListViewItem In ListView1.Items
            
For Each item2 As ListViewItem In ListView1.Items
                
If item.SubItems(3).Text = item2.Text Then MessageBox.Show("Same")
            
Next
        Next 
If this is what you want?


* - Odus - Feb 3, 2016

(Feb 3, 2016 10:06 AM)Arnold Schwarzenegger Wrote:  
PHP Code

<?php 
For Each item As ListViewItem In ListView1.Items
            
For Each item2 As ListViewItem In ListView1.Items
                
If item.SubItems(3).Text = item2.Text Then MessageBox.Show("Same")
            
Next
        Next 
If this is what you want?

You'll want to exit the loop blocks to conclude the search, unless you're searching for >1 match, in which case break only from the nested loop.


* - Nikola Тesla - Feb 4, 2016

(Feb 3, 2016 11:49 AM)Odus Wrote:  You'll want to exit the loop blocks to conclude the search, unless you're searching for >1 match, in which case break only from the nested loop.

Yes i will end loop if result is found , but that depends on user how much name he wants to compare

PHP Code

<?php 
For Each item As ListViewItem In ListView1.Items
     
For Each item2 As ListViewItem In ListView2.Items
         
If item.SubItems(3).Text = item2.Text Then MessageBox.Show("Same") : Exit For
     
Next
  Next 



* - OneTXxL - Feb 10, 2016

thank you very much bro is resolved