Home > DeveloperSection > Forums > ListView CheckedItems find item by name
Jayden Bell
Jayden Bell

Total Post:110

Posted on    September-04-2013 2:34 AM

 C# C# 

 1 Reply(s)
 1418  View(s)
Rate this:

I need to check if an item with a particular name exists in the CheckedItems collection of a ListView.

So far I've tried:

ListViewItem item = new ListViewItem(itemName);

if (listView1.CheckedItems.IndexOf(item) >= 0)

   return true;


ListViewItem item = new ListViewItem(itemName);

if (listView1.CheckedItems.Contains(item))

   return true;

Neither of those worked. Is there a way to do this without looping through CheckedItems and checking them one by one?

Sumit Kesarwani

Total Post:378

Posted on    September-04-2013 7:08 AM

Hi Jayden,

Get rid of newing up a ListViewItem and do this instead:

ListViewItem itemYouAreLookingFor = listView1.FindItemWithText("NameToLookFor");

// Did we find a match?

if (itemYouAreLookingFor != null)


    // Yes, so find out if the item is checked or not?



        // Yes, it is found and check so do something with item here



Don't want to miss updates? Please click the below button!

Follow MindStick