How to set DataSourceUpdateMode in DataGridView
I need the DataGridView to update the cell contents OnPropertyChanged, rather to OnValidate.
The DataGridView is bound to a BindingSource, sourced by a subclass of BindingList with custom business objects.
The DataGridView is for selecting the desired object, that is then bound to common c开发者_如何学Controls on the form, so the user can edit it. It is only odd, that the DataGridView does not get updated while the TextBoxes are edited. The business objects support INotifyPropertyChanged, IEditableObject, IDataErrorInfo.
Any ideas on how to achive this?
It seems it does not work directly by changing the DataSourceUpdateMode
.
You can use the DataGridView CellContentClick
event to find out when the user clicked on the check box or when the user changed the check by hitting the space bar.
At that point you can execute DataGridView::EndEdit
to commit the cell column. And then call BindingSource::EndEdit
to commit the entire row.
You can use the following links to understand and get your solution robust:
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/3aa81b24-2911-44ad-baf4-2619557b374e
http://connect.microsoft.com/VisualStudio/feedback/details/116030/datagridview-lacks-support-for-binding-datasourceupdatemode
精彩评论