I'm using a ListView control with multirow and fullrow select on. When I'm selecting multiple rows at once, some of my rows magically become checked. This happens when dragging the mouse over and also when selecting one, and shift clicking another.
See image describing issue here:
What in the grapefruit is going on? Anyone?
Unfortunately there are bugs in the ListView class, this is one of them. The following code is a fix that worked for me.
Edit: Sorry, this doesn't work quite right, although it does prevent the error that you show in your question. This prevents selecting multiple items and then checking them by clicking the check box.
void SetupListView()
{
listView.ItemCheck += new ItemCheckEventHandler(listView_ItemCheck);
listView.MouseDown += new MouseEventHandler(listView_MouseDown);
listView.MouseUp += new MouseEventHandler(listView_MouseUp);
listView.MouseLeave += new EventHandler(listView_MouseLeave);
}
bool mouseDown = false;
void listView_MouseLeave(object sender, EventArgs e)
{
mouseDown = false;
}
void listView_MouseUp(object sender, MouseEventArgs e)
{
mouseDown = false;
}
void listView_MouseDown(object sender, MouseEventArgs e)
{
mouseDown = true;
}
void listView_ItemCheck(object sender, ItemCheckEventArgs e)
{
if(mouseDown)
{
e.NewValue = e.CurrentValue;
}
}