Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 791
Justen Avatar asked Sep 01 '25 10:09

Justen


2 Answers

In ItemCheck event handler using ItemCheckEventArgs e you can retrive corresponding object

checkedListBox1.Items[e.Index]
like image 122
Nickolodeon Avatar answered Sep 03 '25 01:09

Nickolodeon


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();
}
like image 40
Justin Niessner Avatar answered Sep 03 '25 00:09

Justin Niessner