am using the following code to bind a checkedlistbox in win form.I want to get the value member of of checked items in checkedlistbox ?
listCollection = new List<ListItem>();
listCollection.Add(new ListItem { text = "Manufacturer", value = "1" });
listCollection.Add(new ListItem { text = "Dealer", value = "2" });
listCollection.Add(new ListItem { text = "Distributor", value = "3" });
listCollection.Add(new ListItem { text = "Trader", value = "4" });
listCollection.Add(new ListItem { text = "Service Provider", value = "5" });
chkListCategory.DataSource = listCollection;
chkListCategory.DisplayMember = "text";
chkListCategory.ValueMember = "value";
I don’t know what is
ListItembut I suppose it is a class that is looks like:So, change the
DisplayMember = "text";to"Text"andValueMember = "value";to"Value":The display text at UI will be “Manufacturer, Dealer, Distributor, …”
And the values will be “1, 2, 3, …”
Get the value member of checked items:
To get the values of checked items: