tags:

views:

1433

answers:

2

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

A: 

Out-of-the-box, .NET ListViews (WinForms) in virtual mode do not support checkboxes. They work unreliably and give rise to strange bugs. I've never seen the one you're describing, but it doesn't surprise me.

Your solution is to either:

  1. use a non-virtual ListView
  2. use an ObjectListView, which does support checkboxes on virtual lists
Grammarian
A: 

I've got the exact same problem and I'm not in Virtual Mode. I've run the program in debug mode and though the instruction :

listView1.Items[count].Checked = true;

is executed ('count' being a functional counter), the checkboxes in my listview will not get checked. Sometimes, one or two of them will for no apparent reason, although the line is read for all the checkboxes that want to be checked...

I'd be very interested in any highlight!

Thank you, christophe