NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

BindingManager.Item (Object)

Gets the ListManager associated with the specified data source.

[C#] In C#, this member is the indexer for the BindingManager class.

[Visual Basic]
Overloads Public Default ReadOnly Property Item( _
   ByVal dataSource As Object _
) As ListManager
[C#]
public ListManager this[
   object dataSource
] {get;}
[C++]
public: __property ListManager* get_Item(
   Object* dataSource
);
[JScript]
returnValue = BindingManagerObject.Item(dataSource);
-or-
returnValue = BindingManagerObject(dataSource);

[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed Item property whose type is Object and whose index type is String.

Arguments [JScript]

dataSource
The data source associated with the desired ListManager.

Parameters [Visual Basic, C#, C++]

dataSource
The data source associated with the desired ListManager.

Property Value

A ListManager for the specified data source.

Exceptions

Exception Type Condition
System.IndexOutOfRange The collection doesn't have an element at this index.

Remarks

The Item property (BindingManager indexer) returns the ListManager for a specified data source. For example, imagine a Win Form with two DataGrid controls bound to two different System.WinForms.DataSet objects. Only one ListManager exists for each System.WinForms.DataSet. The BindingManager will return the appropriate ListManager depending on the data source passed to it.

See the ListBinding class for a list of possible data sources and details on creating bindings between controls and data sources.

Example [Visual Basic]

The example below first creates two bindings between two System.WinForms.DataView objects and four controls. The BindingManager is then used to return the ListManager objects for each control given the appropriate data source.

[Visual Basic]

' The following lines go into the Declarations section of the form.
Private lmOrders As ListManager
Private lmProducts As ListManager
Private dvOrders As DataView
Private dvProducts As DataView

Private Sub MakeDataViewObjects()
   ' Not shown: code for getting and populating DataSet objects.
   Dim tOrders As DataTable 
   tOrders = DataSet1.Tables("Orders")
   Dim tProducts As DataTable
   tProducts = DataSet2.Tables("Orders")
   dvOrders = New DataView(tOrders)
   dvProducts = New DataView(tProducts)
End Sub

Private Sub BindControls()
   ' Bind two DataGrid controls and two ComboBoxes to DataView objects.

   Combo1.Bindings.Add("Text", dvProducts, "CompanyName")
   DataGrid1.DataSource = dvProducts
   DataGrid1.DataMember = "Products"

   Combo2.Bindings.Add("Text", dvOrders "Customer")
   DataGrid2.DataSource = dvOrders
   DataGrid2.DataMember = "OrderDetails"
End Sub

Private Sub GetListManagers()
   ' Get the ListManager objects for each data source.
   lmOrders = me.BindingManager(dvOrders)
   lmProducts = me.BindingManager(dvProducts)
End Sub

See Also

BindingManager Class | BindingManager Members | System.WinForms Namespace | BindingManager.Item Overload List | BindingsCollection | ListBinding