c# ListView unable to check a checkbox! Strange problem.

Posted by Kurt on Stack Overflow See other posts from Stack Overflow or by Kurt
Published on 2009-06-29T22:19:01Z Indexed on 2010/06/05 23:02 UTC
Read the original article Hit count: 527

Filed under:
|

This is a strange problem, I've not added much code as I don't know were to start. I have a listview control in virtual mode, if I filter the listview to show me all people called John, I then see 3 users called John, I then cancel the filter setting all values to null and return all data to the listview, I now have several hundred items in the list but I can only see 30 on screen unless I scroll down the listview.

I then use the code below to check a checkbox in each row, all get checked apart from the 3 Johns but if I can see 1 of the 3 Johns in listview without scrolling and then run the code below the visible John is checked.

 for (int i = 0; i < this._items.Count; i++)
            {

                    this._items[i].Checked = true;
            }

I have checked the status of the checkbox just before it is checked in the above code and if John is visible then the checkbox believes it is unchecked (false), if it is not visible it belives it is checked (true). So having one visible John on screen the checkbox looks unchecked and running a test proves it is unchecked, for the two Johns I can't see they believe they are checked but if I scroll down so I can see them they aren't.

Any ideas?

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about listview