I’m passing a List<object> to a method that populates a checkedListBox. My understanding is Object.ToString() associates the object with the checkedListBox item and displays readable string. Object.Name accomplishes this, but then the data isn’t associated with the item. How do I access the ValueMember property of the checkListBox item?
public void CategoryListBox(List<Category> categoryList)
{
checkedListBox1.Items.Clear();
foreach (Category category in categoryList)
{
checkedListBox1.Items.Add(category);
}
}
ValueMember of
CheckBoxListFrom the answer of Mr. codingbiz I did some quick research for this control
checkListBoxaboutValueMemberProperty, so obviously from Intellisense we can’t navigate this.DisplayMemberand.ValueMemberforcheckListBox, so I figured it out that this Property is already included incheckListBoxbut not showing in it. For more detailsTo List all the name
By using Linq we can achieve this.
I hope you can get some idea from this answer.