My check box is not causing the binding source to change when checked.
I have a checkbox that is bound to an SQL table (defined as TinyInt) like so:
//
// overrideCheckBox
//
this.overrideCheckBox.CausesValidation = false;
this.overrideCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("CheckState", this.ProcessingBindingSource, "rtoverride", true));
this.overrideCheckBox.Location = new System.Drawing.Point(354, 378);
this.overrideCheckBox.Name = "overrideCheckBox";
this.overrideCheckBox.Size = new System.Drawing.Size(104, 24);
this.overrideCheckBox.TabIndex = 70;
this.overrideCheckBox.Text = "Override";
this.overrideCheckBox.UseVisualStyleBackColor = true;
this.overrideCheckBox.Visible = false;
It's defined as System.Byte in the table adapter.
I'm using this code to save:
this.ProcessingBindingSource.EndEdit();
this.ProcessingTableAdapter.Update(rMSDataSet);
myDataSet.AcceptChanges();
Every other field saves except my checkbox. I checked my binding source back to my table and everything seems correct except ProcessingBindingSource -> current row -> rtoverride hasn't changed to reflect the new value of checked = 1.
Something is not right and I'm trying to hack through it with something like this:
if (overrideCheckBox.Checked)
{
// in the ProcessingBindingSource at ProcessingBindingSource.Position change the value from 0 to 1
}
this.ProcessingBindingSource.EndEdit();
this.ProcessingTableAdapter.Update(rMSDataSet);
myDataSet.AcceptChanges();
It is not beautiful nor is it the best way to do it but I have to get this done and I can't figure out the syntax.
Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire