Documentation for this section has not yet been entered.
The BindingSource.DataSource property can be set to a number of data sources, including types, objects, and lists of types. The resulting data source will be exposed as a list. The following table shows some of the common data sources and the resulting list evaluation.
null |
An empty System.ComponentModel.IBindingList of objects. Adding an item sets the list to the type of the added item. |
null with BindingSource.DataMember set |
Not supported, raises ArgumentException. |
Non-list type or object of type "T" |
Empty System.ComponentModel.IBindingList of type "T". |
Array instance |
System.ComponentModel.IBindingList containing the array elements. |
IEnumerable instance |
An System.ComponentModel.IBindingList containing the IEnumerable items. |
List instance containing type "T" |
System.ComponentModel.IBindingList instance containing type "T". |
In addition, BindingSource.DataSource can be set to other list types such as System.ComponentModel.IListSource and System.ComponentModel.ITypedList and the System.Windows.Forms.BindingSource will handle them appropriately. In this case, the type contained in the list should have a default constructor.
When setting a data source, if the supplied reference contains more than one list or table, you must set the BindingSource.DataMember property to a string that specifies the list to bind to. Setting this property raises the BindingSource.DataSourceChanged event.
If you make any changes to the BindingSource.DataSource property value, you should do so on the user interface (UI) thread to ensure that the UI reflects the changes.
The BindingSource.DataSource property is the default property for the System.Windows.Forms.BindingSource class.