Initializes a new instance of the System.Data.ListBinding using the specified property name, object, and column.
[Visual Basic] Overloads Public Sub New( _ ByVal propertyName As String, _ ByVal dataSource As Object, _ ByVal dataMember As String _ ) [C#] public ListBinding( string propertyName, object dataSource, string dataMember ); [C++] public: ListBinding( String* propertyName, Object* dataSource, String* dataMember ); [JScript] public function ListBinding( propertyName : String, dataSource : Object, dataMember : String );
Exception Type | Condition |
---|---|
InvalidBindingException | The propertyName isn't an empty string (""), but it isn't a valid property on a control. |
Possible data sources include:
The following example shows several examples of binding a TextBox control to a column in a table in a DataSet, DataView, and DataSetView.
[Visual Basic]
' The next two lines go into the Declarations section of the module: Private myDataSetView As DataSetView ' SuppliersProducts is a class derived from DataSet. Private myDataSet As SuppliersProducts Private Sub CreateDataSetView() ' Not shown: SuppliersProducts is already configured with tables, relations, constraints. myDataSet = New SuppliersProducts myDataSetView = New DataSetView(myDataSet) End Sub Private Sub BindTextBoxToDataSet() ' Call CreateDataSetView first CreateDataSetView() ' Bind a TextBox control to a column in the DataSet. TextBox1.Bindings.Add("Text", myDataSet, "Suppliers.CompanyName") End Sub Private Sub BindTextBoxToDataView() ' Call CreateDataSetView first. CreateDataSetView ' Create the DataView using table from the DataSet. Dim dv As DataView dv = New DataView(myDataSet.Tables("Suppliers")) ' Add the ListBinding. TextBox1.Bindings.Add("Text", myDataSet, "CompanyName") End Sub Private Sub BindTextBoxToDataSetView() ' Call CreateDataSetView first. CreateDataSetView. ' Add the ListBinding. TextBox1.Bindings.Add("Text", myDataSet, "Suppliers.CompanyName") End Sub
ListBinding Class | ListBinding Members | System.WinForms Namespace | ListBinding Constructor Overload List | BindingsCollection | ListManager