I am trying to bind a checkbox contained within a winforms data repeater, however the checkbox itself it not ticking. When binding to a label it works
lbSchoolFri.DataBindings.Add("Text", bindingSource5, "SchoolName");
Checkbox (not working) -
cbSchoolFri.DataBindings.Add("Checked", bindingSource5, "SchoolContacted");
Any ideas why this is not working?
Thanks
If it is a bit (0 or 1), you have to add Format
event handler for your Binding
:
Binding bind = new Binding("Checked", bindingSource5, "SchoolContacted");
bind.Format += (s,e) => {
e.Value = (int)e.Value == 1;
};
cbSchoolFri.DataBindings.Add(bind);
This is a very basic task when you work with Binding
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With