How would I get the text of the newly checked item in a checked listbox with C#

Justen picture Justen · Nov 17, 2010 · Viewed 16.1k times · Source

I'm using the ItemCheckEventArgs and from which I can get an index value, but from this value I'm not sure how to look up what the text is of whatever was checked.

Answer

Justin Niessner picture Justin Niessner · Nov 17, 2010

Here's some bare-bones code that should do the trick:

public void CheckedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
{
    var checkedListBox = (CheckedListBox)sender;
    var checkedItemText = checkedListBox.Items[e.Index].ToString();
}