Windows应用程序中的复选框 [英] checkbox in windows application

查看:112
本文介绍了Windows应用程序中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在修复现有c#Windows应用程序中的错误.
问题是与绑定名为chkFName的复选框控件有关.
如果是第一次,我在DataGridView(DGV)中选择了一行,则chkFName根据DGV中的一个字段显示为勾选或取消勾选,但是如果我在网格中选择了另一行,则chkFName仍然保持不变,因此不会在chkFName中显示新字段的状态.


您知道代码中出了什么问题吗?
谢谢

有绑定源控件,用于将控件数据绑定到数据...
绑定源称为MyBS

控件绑定到数据的方式如下:

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:

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));

推荐答案

请参阅此内容,可能会对您有所帮助
http://stackoverflow.com/questions/820947/databinding-for-checkbox-with-stringvalues [^ ]
http://social.msdn.microsoft.com /Forums/zh-CN/winformsdatacontrols/thread/9ec1709f-4e06-4a77-8812-379d0d34a82c/ [
Refer this, might help you
http://stackoverflow.com/questions/820947/databinding-for-checkbox-with-stringvalues[^]
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/9ec1709f-4e06-4a77-8812-379d0d34a82c/[^]


这篇关于Windows应用程序中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆