DataGridView复选框列不对基础绑定对象应用更改 [英] DataGridView CheckBox column doesn't apply changes to the underlying bound object

查看:130
本文介绍了DataGridView复选框列不对基础绑定对象应用更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 Record 的对象,用作DataGridView中的行。
每个记录有一个新的布尔值帮助。果然,这个新价值显示为我的形式的复选标记。

I have a list of Record objects that serve as rows in my DataGridView. Each Record has a new bool value Helped. Sure enough, this new value shows up as check mark in my form.

目前,当这个框被选中时,似乎没有更改帮助 bool在相应的记录

As it stands currently, when this box is checked it doesn't seem to change the value of Helped bool in the corresponding Record.

是否有某种只读属性我需要更改?如何通过点击我的表单作为其 DataSource 的价值变化?

Is there some sort of read-only property I need to change? How do I pass a click on my form back as a change in value of its DataSource?

编辑:我我发现 System.Windows.Forms.DataGridViewEditMode.EditOnEnter 属性,但我还没有看到我的 Record.Helped 属性更新。

I've found the System.Windows.Forms.DataGridViewEditMode.EditOnEnter property, but I'm still not seeing my Record.Helped property get updated.

推荐答案


目前,当这个框被选中时,似乎不是
更改相应记录中的帮助bool的值。

As it stands currently, when this box is checked it doesn't seem to change the value of Helped bool in the corresponding Record.

您在 DataGridView ,在完成编辑单元格之前,不会立即提交到数据源,然后更改将被推送到数据源。如果由于任何原因想要更快地推送更改,可以调用:

The changes which you make on a cell of DataGridView, doesn't commit immediately to the data source until you finish editing the cell, then changes will be pushed to data source. If for any reason you want to push changes sooner, you can call:

dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);

例如,您可以在 CellContentClick 您的 DataGridView 的事件将复选框值推送到数据源的底层属性。

For example you can do that in CellContentClick event of your DataGridView to push check box value to the underlying property of data source.

这篇关于DataGridView复选框列不对基础绑定对象应用更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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