如果在输入不正确的情况下回滚gridview中的更改 [英] How to roll back changes in gridview in case of incorrect input
问题描述
我有一个绑定到对象的列表一个DataGridView。它有一些列,用户可以编辑。但是也有一些不允许一行作为一个整体一定的投入。我怎么可以回滚,如果用户在某些单元格输入无效投入。
我尝试使用RowValidating事件处理程序,但后单元格值已更改它不叫。甚至当我implemet CellValueChanged,我仍然无法回滚所做的更改。
...
不知道如何做到这一点。
I have a DataGridView that is bound to a list of object. It has some columns that the user can edit. There are certain inputs that are not allowed for a row as a whole. How can I roll back if the user enters invalid inputs in some cell. I tried using the RowValidating event handler but it was not called after cell value has been changed. Even when I implemet CellValueChanged, I still cannot roll back the changes. ... Any idea how to accomplish this
推荐答案
在数据绑定存在,对我来说它的工作原理搭配:
When databinding exists, for me it works with:
myBindingSource.CancelEdit();
myDataGridView.RefreshEdit();
这篇关于如果在输入不正确的情况下回滚gridview中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!