CheckBox.DataBindings.Add不工作 [英] CheckBox.DataBindings.Add not working
本文介绍了CheckBox.DataBindings.Add不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图绑定包含一个WinForms数据中继器内的复选框,但是该复选框它本身不是滴答作响。当绑定到一个标签,它的工作原理
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?
感谢
推荐答案
如果它是一个位(0或1),你必须添加格式
事件处理程序的绑定
:
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
.
这篇关于CheckBox.DataBindings.Add不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文