ArtK ArtK - 11 months ago 43
C# Question

Can't get correct value from Item in CheckedBoxList

Given that I added an item to

this way:


And let's say that this is the only item in the control:

string s = checkedListBox1.GetItemText(0);

Now the value of s is
when I expect
. Why can't I get correct value using
checkedListBox1.GetItemText(int itemIndex)

Answer Source

You should pass the object which is an item of CheckedListBox to GetItemText:


Otherwise GetItemText returns ToString of passed object.