C# 将多个复选框绑定到绑定源
我有一个程序和一个表单,其中有多个复选框绑定到一个数据源。 我只是通过从数据源拖动细节并将复选框放到表单上来创建它 在表单的顶部有一个绑定导航器,其中包含一个保存按钮。保存按钮的代码:C# 将多个复选框绑定到绑定源,c#,winforms,visual-studio-2012,checkbox,datasource,C#,Winforms,Visual Studio 2012,Checkbox,Datasource,我有一个程序和一个表单,其中有多个复选框绑定到一个数据源。 我只是通过从数据源拖动细节并将复选框放到表单上来创建它 在表单的顶部有一个绑定导航器,其中包含一个保存按钮。保存按钮的代码: private void earndeductmasterBindingNavigatorSaveItem_Click(object sender, EventArgs e) { try { this.Validat
private void earndeductmasterBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
try
{
this.Validate();
this.earndeductmasterBindingSource.EndEdit();
this.earndeductmasterTableAdapter.Update(this.eko_payrollDataSet.earndeductmaster);
this.eko_payrollDataSet.earndeductmaster.AcceptChanges();
this.earndeductmasterTableAdapter.Fill(this.eko_payrollDataSet.earndeductmaster);
MessageBox.Show("Earning/Deduction details updated successfully");
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
我能够正确添加/删除/更新记录,但复选框除外。例如,如果我选中“高级”复选框并单击“保存”,则“重复类型”复选框将自动选中,反之亦然
我可能做错了什么?手动解决了每个复选框的绑定问题。e、 g
cbRecurrence.DataBindings.Add(new Binding("Checked", earndeductmasterBindingSource, "recurrenceType", true));