基础数据databable不会从datagridview获取行

发布于 2025-02-12 09:08:28 字数 1201 浏览 1 评论 0原文

现在,对于某人来说,这可能很明显,但是我恰恰相反:

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).

enter image description here

When I click on a cell a cursor icon appears near that asterisk.

enter image description here

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.

enter image description here

enter image description here

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.

enter image description here

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 技术交流群。

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

发布评论

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

评论(1

温柔嚣张 2025-02-19 09:08:28

调用endedit bindingsource。绝对不要调用Acceptchanges!直到您实际保存了更改,否则才会被调用。当您在适配器上调用更新时,它将被隐式调用。如果您先调用它,则不会保存更改。

Call EndEdit on the BindingSource. DEFINITELY do not call AcceptChanges! That doesn't get called until you have actually saved the changes. It will be invoked implicitly when you call Update on your adapter. If you call it first then there will be no changes to save.

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