Which CheckedListBox event triggers after a item is checked?

前端 未结 12 568
攒了一身酷
攒了一身酷 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:37

    I tried this and it worked:

        private List m_list = new List();
        private void Initialize()
        {
            for(int i=0; i < checkedListBox1.Items.Count; i++)
            {
                m_list.Add(false);
            }
        }
    
        private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.NewValue == CheckState.Checked)
            {
                m_list[e.Index] = true;
                checkedListBox1.SetItemChecked(e.Index, true);
            }
            else
            {
                m_list[e.Index] = false;
                checkedListBox1.SetItemChecked(e.Index, false);
            }
        }
    

    determine by index of the list.

提交回复
热议问题