How to: Bind a Windows Forms ComboBox or ListBox Control to Data
To bind a ComboBox or ListBox control
Set theDataSource property to a data source object. Possible data sources include a BindingSource bound to data, a data table, a data view, a dataset, a data view manager, an array, or any class that implements the IList interface. For more information, see Data Sources Supported by Windows Forms.
If you are binding to a table, set theDisplayMember property to the name of a column in the data source.
- or -
If you are binding to an IList, set the display member to a public property of the type in the list.
Private Sub BindComboBox() ComboBox1.DataSource = DataSet1.Tables("Suppliers") ComboBox1.DisplayMember = "ProductName" End Sub
If you are bound to a data source that does not implement the IBindingList interface, such as an ArrayList, the bound control's data will not be updated when the data source is updated. For example, if you have a combo box bound to an ArrayList and data is added to the ArrayList, these new items will not appear in the combo box. However, you can force the combo box to be updated by calling the SuspendBinding and ResumeBinding methods on the instance of the BindingContext class to which the control is bound.