datagridview单元格编辑错误

发布于 2024-08-29 08:19:06 字数 390 浏览 1 评论 0原文

在 Windows 窗体上,我有一个未绑定的 datagridview 和 1 个用户可编辑的列。用户单击其中一个单元格,改变主意并使用“x”关闭表单。然后他试图再次调出表格。出现以下错误:

“System.InvalidOperationException:操作未成功,因为程序无法提交或退出单元格值更改”

该错误实际上发生在我在通过 show.dialog 显示表单之前执行 datagridview.rows.clear 的情况。

我将 DataGridView.CancelEdit() 添加到 FormClosing 事件,但错误仍然存​​在。

我尝试注释掉 rows.clear 代码,但随后每行出现两次。 datagridview的数据源是一个集合。

感谢您的所有帮助。

On a Windows form I have an unbound datagridview with 1 user-editable column. A user clicked into one of those cells, changed his mind and closed the form using the "x". Then he tried to bring up the form again. The following error came up:

"System.InvalidOperationException: Operation did not succeed because the program cannot commit or quit a cell value change"

The error actually occurs where I do a datagridview.rows.clear before displaying the form via a show.dialog.

I added a DataGridView.CancelEdit() to the FormClosing event but the error remains.

I tried to comment out the rows.clear code but then each row appeared twice. The data source of the datagridview is a collection.

Thanks for all help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青柠芒果 2024-09-05 08:19:06

我设置了表单的实例= Nothing,问题就消失了

I set the instance of the form = Nothing and the problem disappeared

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文