I am having trouble with the checkedListbox.
I would like to bind list(of pages) where the pages class has 2 properties
I can do this using:
Me.CheckedListBox1.DataSource = Me.mLstPages
Me.CheckedListBox1.DisplayMember = “Name”
Me.CheckedListBox1.ValueMember = “IsChecked”
However, if I have the “IsChecked” property set to true, the checkboxes are not checked.
What am I doing wrong?
The ValueMember is the name of the property in the data source that provides the value for the items.
The DisplayMember is the name of the property in the data source that provides the value used to dispay the items.
If you use “IsChecked” as the name of the ValueMember and your data source has a property IsChecked, it will simply bind the value to that property. It is not related to the checked state of an item. Items do not have a checked state since their type is entirely up to your application. That’s the standard implementation in WinForms.
There would have to be a third binding property, something like CheckStateMember. It can be an enhancement for when we add binding to the ListView and possibly the TreeView.
One way to do this would be override RefreshItems() and in there loop over the items:
for (int i = 0; i < this.Items.Count; i++)
It obviously depends on your binding source and your classes in the app.
Please login first to submit.