为什么我绑定的 DataGridView 抛出“操作无效,因为它导致对 SetCurrentCellAddressCore 函数的可重入调用"?错误? [英] Why is my bound DataGridView throwing an "Operation not valid because it results in a reentrant call to the SetCurrentCellAddressCore function" error?
问题描述
将 DataGridView
控件绑定到绑定源时,我的应用程序出现以下错误:
When binding a DataGridView
control to a binding source, I'm getting the following error in my application:
操作无效,因为它导致对 SetCurrentCellAddressCore 函数的可重入调用
Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function
绑定源依赖于数据表.我正在过滤 DataGridView 中的记录.我在过滤 DataGridView 的地方使用了 dataGridView1_CellValueChanged()
事件.但是当我从当前单元格中删除数据时,就会出现这个错误.
The binding source depends on the data table. And I'm filtering the records from the DataGridView. And I used the dataGridView1_CellValueChanged()
event where I'm filtering the DataGridView. But when I was deleting the data from the current cell, this error occurs.
我该如何解决这个问题?
How can I resolve this problem?
推荐答案
该异常由 DataGridView
引发,以防止发生无限循环.造成这种情况的原因通常是以下之一:
The exception is raised by the DataGridView
in order to prevent an infinite loop from occurring. The cause of this is usually one of the following:
- 在当前活动单元格上执行操作时更改活动单元格
- 在单元格编辑正在进行时开始、结束或取消编辑模式
- 在
DataGridView
仍在使用它时导致活动单元格被更改的任何其他操作
- Changing the active cell while an operation is being performed on the currently-active cell
- Beginning, ending or cancelling edit mode while a cell edit is already in-progress
- Any other operation that results in the active cell being changed while the
DataGridView
is still using it
查看您的 CellValueChanged
事件处理程序,并确保您没有在处理程序中执行上述任何操作.
Have a look at your handler for the CellValueChanged
event and make sure you are not doing any of the above within the handler.
这篇关于为什么我绑定的 DataGridView 抛出“操作无效,因为它导致对 SetCurrentCellAddressCore 函数的可重入调用"?错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!