DataGridViewCheckBoxColumn:如何在属性更改时而不是在验证时更新绑定数据源
我有一个 BindingList 绑定为 DataGridView 的数据源; TSource 属性之一绑定到 DataGridViewCheckBoxColumn,但数据源不是在单击复选框时更新,而是在复选框本身的焦点丢失时更新。
我知道当 DataSourceUpdateMode 为“OnValidation”而不是“OnPropertyChanged”时,标准 WindowsForms 绑定上会发生类似的情况,但如何使用 DataGridViewCheckBoxColumn 获得相同的结果?
该列定义如下:
DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();
column.DataPropertyName = "MyProperty";
column.HeaderText = "Title";
dataGridView.Columns.Add(column);
I've got a BindingList binded as the data source of a DataGridView; one of the TSource properties is binded to a DataGridViewCheckBoxColumn, but the data source is updated not when a click on the checkbox occurs, but when the focus on the checkbox itself is lost.
I know that something similar happens on a standard WindowsForms binding when the DataSourceUpdateMode is "OnValidation" instead of "OnPropertyChanged", but how can I have the same results with a DataGridViewCheckBoxColumn?
The column is defined as follows:
DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();
column.DataPropertyName = "MyProperty";
column.HeaderText = "Title";
dataGridView.Columns.Add(column);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过处理
DataGridView
的CurrentCellDirtyStateChanged
事件来完成此操作。You can do this by handling the
CurrentCellDirtyStateChanged
event of theDataGridView
.