Connecting Tech Pros Worldwide Help | Site Map

How do I get all the selected values from a CheckedListBox?

Newbie
 
Join Date: Aug 2009
Posts: 1
#1: Aug 21 '09
CheckedListBox1.SelectedValue does not seem to have a mechanism for identifying the selected items. It just takes the first item. There doesn't seem to be a way to relate checked items to selected values.

Is there a way to get the selected value for all checked items in a checkedListBox?

Thanks
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,745
#2: Aug 21 '09

re: How do I get all the selected values from a CheckedListBox?


"Items" in a checkbox's Items collection have multiple properties. Including a value different than what is displayed. You can display "Fred" and have a value of '5'

Most times we just need a list of string and we are good with that
Items[0] = "Fred"
Items[1] = "Barney"
Items[2] = "Wilma"
and so on

If you just need that text you can do this...

String Person = CheckedListBox1.SelectedItem as string;
Reply