Compare Dataset with Listview Items VB 2005

Hello,
I hope that you can help me...
I need to compare a single column recordset with the contents of a listviews subitems.
This has to return a true or false. I know that this can be done with a loop but I was hopeful of a cool trick or subroutine that would accomplish this...

Any Ideas?
fullbuggAsked:
Who is Participating?
 
Walter RitzelConnect With a Mentor Senior Software EngineerCommented:
If the type of data on the recordset and in the listview items are the same, you can use the Contains method on the Listview.Items. Example:

if (lvListView.Items.Contains(value from recordset))
{
  found it!!!1
}
0
 
fullbuggAuthor Commented:
Thanks for the reply... The "Value from recordset" is a string?
If so I am getting an error the string cannot be converted to a listviewitem.
0
 
Walter RitzelSenior Software EngineerCommented:
I think I made a mistake....
instead of using a string directly, you need to create a listviewitem there, like this:
new ListViewItem("value from recordset")
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.