All I need to do is enable a few buttons whenever at least one item in my ListView is checked. I tried using ItemCheck event but it seems to execute my code before it actually changes the Checked property of the item I change. That might be just fine if it weren't that if I have a ListView with only one item in, and that item is checked, trying to uncheck it results in enabling of those buttons too, when I really want them to be disabled.
Question is, what event and what kind of code do I need to exploit

ListViewItem checked status change
Caga
Junrei
private void OnItemCheck ( object sender, ItemCheckEventArgs e )
{
int nCt = listView1.CheckedItems.Count;
if (e.NewValue == CheckState.Checked)
++nCt;
else
--nCt;
button1.Enabled = (nCt > 0);
}
In .NET 2.0 you can handle the ItemChecked event instead. This is raised after the item is checked/unchecked and is better suited for post-change events like enabling or disabling items.
private void OnItemChecked ( object sender, ItemCheckedEventArgs e )
{
button1.Enabled = (listView1.CheckedItems.Count > 0);
}
Michael Taylor - 12/10/05