Which CheckedListBox event triggers after a item is checked?

前端 未结 12 567
攒了一身酷
攒了一身酷 2020-11-28 13:24

I have a CheckedListBox where I want an event after an item is checked so that I can use CheckedItems with the new state.

Since ItemChecked is fired before

12条回答
  •  醉话见心
    2020-11-28 13:54

    I tried this and it worked:

    private void clbOrg_ItemCheck(object sender, ItemCheckEventArgs e)
    {
        CheckedListBox clb = (CheckedListBox)sender;
        // Switch off event handler
        clb.ItemCheck -= clbOrg_ItemCheck;
        clb.SetItemCheckState(e.Index, e.NewValue);
        // Switch on event handler
        clb.ItemCheck += clbOrg_ItemCheck;
    
        // Now you can go further
        CallExternalRoutine();        
    }
    

提交回复
热议问题