Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am fixing a bug in an existing c# windows application.
The problem is to do with binding the checkbox control which is called chkFName.
If for the first time, I select a row in the DataGridView (DGV), then the chkFName shows ticked or unticked according to one of the fields in the DGV, BUT if I select a different row in the grid, then the state of the chkFName still remains as it was before and therefore it does not show the state of the new field in the chkFName.


Do you know what is going wrong in the code please?
Thanks

There is bindingsource control used for databinding the controls to the data...
Bindingsource is called MyBS

The controls are being bound to the data as follows:
C#
dt = DataGet(mID);
 MyBS.DataSource = dt;
dGV.DataSource = MyBS;

dGV.AutoGenerateColumns = false;

dGV.Columns[i++].DataPropertyName = "PB";
...
...
...
dGV.Columns[i++].DataPropertyName = "FName";

txtPB.DataBindings.Clear();
...
...
...
chkFName.DataBindings.Clear();

tbPB.DataBindings.Add(new Binding("Text", this.MyBS, "PB", true));
...
...
...
chkFName.DataBindings.Add(new Binding("Checked", this.MyBS, "FName", true));
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900