Gets or sets the data source that the connector binds to.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Theproperty 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.
An empty IBindingList of objects. Adding an item sets the list to the type of the added item.
null with DataMember set
Not supported, raises ArgumentException.
Non-list type or object of type "T"
Empty IBindingList of type "T".
IBindingList containing the array elements.
List instance containing type "T"
IBindingList instance containing type "T".
When setting a data source, if the supplied reference contains more than one list or table, you must set the DataMember property to a string that specifies the list to bind to. Setting this property raises the DataSourceChanged event.
If you make any changes to theproperty value, you should do so on the user interface (UI) thread to ensure that the UI reflects the changes.
The BindingSource class.property is the default property for the
The following code example assigns a list of customers to the BindingSource component. This code example is part of a larger example provided at How to: Raise Change Notifications Using the BindingSource ResetItem Method.of a
Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Me.Load ' Create and populate the list of DemoCustomer objects ' which will supply data to the DataGridView. Dim customerList As List(Of DemoCustomer) = _ New List(Of DemoCustomer) customerList.Add(DemoCustomer.CreateNewCustomer()) customerList.Add(DemoCustomer.CreateNewCustomer()) customerList.Add(DemoCustomer.CreateNewCustomer()) ' Bind the list to the BindingSource. Me.customersBindingSource.DataSource = customerList ' Attach the BindingSource to the DataGridView. Me.customersDataGridView.DataSource = Me.customersBindingSource End Sub
Available since 2.0