基础数据databable不会从datagridview获取行
现在,对于某人来说,这可能很明显,但是我恰恰相反:
DataGridView绑定到绑定的源,并且绑定源被绑定到数据表。
DataGridView现在显示一个空排(带有星号)。
当我单击一个单元格时,光标图标出现在该星号附近。
现在我正在该行中输入数据。当我在第一个单元格中输入一个值时,将出现一个新的行,并且星号图标移至该行。 CellValueChanged被触发,但是在手表窗口中,数据表仍然没有该行。
我正在完成所有列并按下保存按钮,但仍在手表窗口中看到了基础DataTable没有握住该行。
如何将其更改回DataTable?单击该保存按钮后,我需要调用某些方法吗?我已经尝试使用_detailDataTable.acceptchanges();但是什么都没发生。
Now, this one can be very obvious for someone, but I am stuck right on this:
Datagridview is bound to a binding source and the binding source is bound to a datatable.
Datagridview is now showing an empty row (with an asterisk).
When I click on a cell a cursor icon appears near that asterisk.
Now I am entering data in that row. When I enter a value in the first cell, a new row appears underneath this one, and the asterisk icon moves to that row. CellValueChanged gets fired, BUT in the watch window, the datatable still doesn't have that row.
I am finishing all columns and hitting a save button, BUT still in the watch window is see that the underlying datatable is not holding that row.
How to get that change back to datatable? Do I need to call some method after clicking that save button? I've tried with _detailDataTable.AcceptChanges(); but nothing happened.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用
endedit
bindingsource
。绝对不要调用Acceptchanges
!直到您实际保存了更改,否则才会被调用。当您在适配器上调用更新
时,它将被隐式调用。如果您先调用它,则不会保存更改。Call
EndEdit
on theBindingSource
. DEFINITELY do not callAcceptChanges
! That doesn't get called until you have actually saved the changes. It will be invoked implicitly when you callUpdate
on your adapter. If you call it first then there will be no changes to save.