views:

75

answers:

1

I have been scratching my head with this error for at least an hour, what the heck is wrong here?

In a loop:

if (selectedItems[x].ImageIndex == 3)
                        {
                            List<ListViewItem> dupes = CP.listCache.FindAll(delegate(ListViewItem item) { return item.Text == selectedItems[x].Text; });

                            if (dupes != null && dupes.Count == 1)
                                dupes[0].ImageIndex = 0;
                        }

I can access the imageIndex, but not set it. ArgumentOutOfRange exception occurs.

A: 

Make sure you know what what's throwing your ArgumentOutOfRange exception -- that's your first problem. Is x a valid index into selectedItems? Is the index you're setting into your image list valid? Remember, indexes are zero-based, not 1-based.

tylerl