slandau
slandau

Reputation: 24102

CheckedListBox iterate over items

So I'm iterating through all the checked items in the box like this:

for (int i = 0; i < listFiles.CheckedItems.Count; i++)
{

}

This works but how do I access the display name property of each of the checked items as I get to it. Seems simple but I can't find it.

Upvotes: 1

Views: 2532

Answers (2)

Fr&#233;d&#233;ric Hamidi
Fr&#233;d&#233;ric Hamidi

Reputation: 263147

If you don't use the DisplayMember property to customize the way your items are rendered, you only need to call their ToString() method:

foreach (object item in listFiles.CheckedItems) {
    string displayName = item.ToString();
    // ...
}

Upvotes: 2

dzendras
dzendras

Reputation: 4751

     foreach (string itemName in listFiles.CheckedItems)
     {


     }

Upvotes: 1

Related Questions