开发者

Can't seem to be able to set ListViewItem.imageIndex

开发者 https://www.devze.com 2022-12-29 13:33 出处:网络
I have been scratching my head with this error for at least an hour, what the heck is wrong here? In a loop:

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 &a开发者_如何学运维mp;& dupes.Count == 1)
                                dupes[0].ImageIndex = 0;
                        }

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号