.NET 中的数据绑定 - 数据表、数据视图和 BindingSource

发布于 2024-09-29 17:50:02 字数 273 浏览 0 评论 0原文

当在 Visual Studio 中绑定到数据表时,它将绑定源的数据源设置为选定的数据表 - 这很好并且是预期的。然而,数据源实际上指向该数据表的数据视图。

我目前正在实现自定义业务对象基类,其中包括集合类。我感觉某种视图会很方便,因为当对这些集合进行排序时,我会出现奇怪的行为,例如,当 bindingsource.position 设置为集合中的最后一个项目时,随机项目位置会发生变化。

我只是想知道当设计器中没有数据视图实例时,微软如何将绑定源绑定到数据视图而不是数据表。

马龙

When binding to datatables in visual studio, it sets the datasource of a bindingsource to the selected datatable - which is fine and is what is expected. However, the datasource is actually pointing to a dataview of that datatable.

I'm currently implementing custom business object base classes which include collection classes. I'm heading towards the feeling some sort of view would be handy as I'm getting odd behaviour when these collections are sorted such as random item position changes when the bindingsource.position is set to the last item in the collection.

I'm just wondering how Microsoft goes about getting the bindingsource to be bound to a dataview instead of a datatable when there isn't a dataview instance anywhere in the designer.

Marlon

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

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

发布评论

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

评论(1

甜`诱少女 2024-10-06 17:50:02

所有DataTables都有一个由BindingSource使用的默认视图。请参阅DefaultView 属性了解详细信息。

All DataTables have a default view which is used by the BindingSource. See the DefaultView property for details.

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