Databinding in .NET - Datatables, Dataviews and BindingSources
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 cla开发者_StackOverflowsses 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
All DataTables
have a default view which is used by the BindingSource
. See the DefaultView
property for details.
精彩评论