.NET 中的数据绑定 - 数据表、数据视图和 BindingSource
当在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有
DataTables
都有一个由BindingSource
使用的默认视图。请参阅DefaultView
属性了解详细信息。All
DataTables
have a default view which is used by theBindingSource
. See theDefaultView
property for details.