No ItemChecked event in a CheckedListBox?

后端 未结 4 1136
故里飘歌
故里飘歌 2020-11-29 08:53

The ListView control has an ItemCheck event which is fired before the item changes, and an ItemChecked event that is fired aft

4条回答
  •  醉话见心
    2020-11-29 09:54

        private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e) {
            int count = this.checkedListBox1.CheckedItems.Count;
            if (e.CurrentValue != CheckState.Checked && e.NewValue == CheckState.Checked) {
                count += 1;
            } else if (e.CurrentValue == CheckState.Checked && e.NewValue != CheckState.Checked) {
                count -= 1;
            }
            this.okButton.Enabled = count > 0;
        }
    

提交回复
热议问题