У меня есть флажок, который проверял значение, привязан к источнику привязки, привязанному к столбцу таблицы булевых данных. Когда я нажимаю кнопку «Сохранить», чтобы переместить мои изменения в моей таблице данных на мой SQL-сервер, значение в таблице данных никогда не изменяется.Связанный флажок не обновляет свой источник данных
Код дизайнера.
this.cbxKeepWebInfinityChanges = new System.Windows.Forms.CheckBox();
this.preProductionBindingSource = new System.Windows.Forms.BindingSource();
//
// cbxKeepWebInfinityChanges
//
this.cbxKeepWebInfinityChanges.AutoSize = true;
this.cbxKeepWebInfinityChanges.DataBindings.Add(new System.Windows.Forms.Binding("Checked", this.preProductionBindingSource, "WEBINFINTY_CHANGES", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
this.cbxKeepWebInfinityChanges.Location = new System.Drawing.Point(6, 98);
this.cbxKeepWebInfinityChanges.Name = "cbxKeepWebInfinityChanges";
this.cbxKeepWebInfinityChanges.Size = new System.Drawing.Size(152, 17);
this.cbxKeepWebInfinityChanges.TabIndex = 30;
this.cbxKeepWebInfinityChanges.Text = "Keep WebInfinity Changes";
this.cbxKeepWebInfinityChanges.UseVisualStyleBackColor = true;
this.cbxKeepWebInfinityChanges.CheckedChanged += new System.EventHandler(this.CauseApplyChangesActivation);
//
// preProductionBindingSource
//
this.preProductionBindingSource.AllowNew = false;
this.preProductionBindingSource.DataMember = "PreProduction";
this.preProductionBindingSource.DataSource = this.salesLogix;
Сохранить Код
//the comments are the debugger values before the call in going from checked when loaded to unchecked when saved.
private void btnApplyChanges_Click(object sender, EventArgs e)
{
(...) // non related saving logic for other controls
preProductionBindingSource.EndEdit(); // checked = false, databinding = true, datatable = true
preProductionTableAdapter.Update(salesLogix.PreProduction); // checked = false, databinding = true, datatable = true
}
То же самое происходит при переходе от бесконтрольно к проверке. Другие элементы, которые я привязал к одному и тому же источнику привязки данных (у меня есть два поля со списком), обновляются корректно.
EDIT - Добавление cbxKeepWebInfinityChanges.DataBindings["Checked"].WriteValue();
до preProductionBindingSource.EndEdit();
ничего не изменило.