Represents a single binding between a DataColumn in a DataTable and the property of a component.
Object
ListBinding
[Visual Basic] Public Class ListBinding [C#] public class ListBinding [C++] public __gc class ListBinding [JScript] public class ListBinding
ListBinding objects are added to the BindingsCollection of controls through the Bindings property. These controls include:
Each ListBinding object is managed by a ListManager To return the appropriate ListManager for a specified data source, use the BindingManager.
Namespace: System.WinForms
Assembly: System.WinForms.dll
The following example creates a ListBinding of a column in a DataTable to a TextBox control. The BindingManager is used to return the ListManager for the binding, which can then be used to advance the Position of the System.WinForms.Listmanager.
[Visual Basic]
' The next 4 lines go into the Declarations section of the form. Private myListManager As ListManager ' SuppliersProducts is a class derived from DataSet. Private ds As SuppliersProducts Private isBound As Boolean Private Sub InstantiateDataSet() ' The methods to populate the DataSet are not shown here. Set ds = New SuppliersProducts End Sub Private Sub BindTextBox() ' Test if the TextBox is already bound. If isBound Then Exit Sub ' Otherwise, bind the TextBox.Text property to the Suppliers.CompanyName column. TextBox1.Bindings.Add("Text", ds.Tables("Suppliers"), "CompanyName") isbound = True End Sub Private Sub GetListManager() ' Get the ListManager for the bound control using the BindingManager ' of the Win Form. To get the ListManager, pass the data source of the ' desired ListManager to the BindingManager. myListManager = Me.BindingManager(ds.Tables("Suppliers"), "") End Sub Private Sub MoveNext() ' To navigate the ListManager, increment the Position property. If myListManager.Position = myListManager.Count - 1 Then MessageBox.Show("End of records") Else myListManager.Position += 1 End If End Sub Private Sub MovePrevious() ' To navigate the ListManager, increment the Position property. If myListManager.Position = 0 Then MessageBox.Show("First record") Else myListManager.Position -= 1 End If End Sub Private Sub MoveFirst() ' Move to position 0 in the list. myListManager.Position = 0 End Sub Private Sub MoveLast() ' Move to the count -1 position. myListManager.Position = myListManager.Count - 1 End Sub
ListBinding Members | System.WinForms Namespace | BindingManager | System.Data.ListManager