views:

56

answers:

1
+1  Q: 

Checked list box

i want to do some actions when all items in checked list box are unchecked. There is only event ItemCheck but the check state is not updated until after the ItemCheck event occurs. I have a button and i want to do its enabled false when all items unchecked in checked list box

System::Void frmMain::clbInstPrgs_ItemCheck(System::Object^  sender, System::Windows::Forms::ItemCheckEventArgs^  e) {
 if ((clbInstPrgs->CheckedIndices->Count == 1)&&(rbnSelectSaveProgramms->Enabled)) {
        btnNext->Enabled = false;
     } else {
        btnNext->Enabled = true;
 }
    return;
}
A: 

If you only have one item checked, and you are in the event handler because you are unchecking something, you will end up with nothing checked.

Here is a answer in VB. Should convert easily.

btnNext.Enabled = Not (clbInstPrgs.CheckedItems.Count = 1 AndAlso e.NewValue = CheckState.Unchecked)
Carter