0

Hi, I'm using this code to check items from a checkedlistbox and see it in my listbox, I don't know what's the problem, I checked with a breakpoint and apparently the ItemCheck event is not being considered by the debugger.
Here's my code.

public void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.NewValue == CheckState.Checked)
            {



            listBox1.Items.Add(checkedListBox1.SelectedItem.ToString());
        }
        else 
        {
            listBox1.Items.Remove(checkedListBox1.SelectedItem.ToString());
        }
    }

    private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        listBox1.Text = checkedListBox1.SelectedItem.ToString();
    }
2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by nmaillet
0

I ran your code, and it seems to be working fine (although you should probably use e.Index instead of checkedListBox1.SelectedItem). Did you register the methods with the corresponding events, either through Visual Studio's properties panel, or with the following code (in the Form's constructor)?

checkedListBox1.ItemCheck += checkedListBox1_ItemCheck;
checkedListBox1.SelectedIndexChanged += checkedListBox1_SelectedIndexChanged;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.